import*as e from"../../legacy.js";import*as t from"../../../../third_party/codemirror.next/codemirror.next.js";import*as i from"../../../../core/platform/platform.js";import*as n from"../../../../core/common/common.js";import*as s from"../../../components/helpers/helpers.js";import*as o from"../../../lit-html/lit-html.js";import*as r from"../../../../core/host/host.js";import*as a from"../../../../core/i18n/i18n.js";import*as l from"../color_picker/color_picker.js";import*as h from"../../../../core/sdk/sdk.js";import*as d from"../../../../models/text_utils/text_utils.js";import*as c from"../../../components/icon_button/icon_button.js";import*as u from"../../../../panels/css_overview/css_overview.js";const p=t.css.cssLanguage.parser,m=new Intl.NumberFormat("en",{maximumFractionDigits:2});function g(e,t){for(let i=t;i<e.length;i++)if(!isNaN(e[i].input))return i;return-1}function v(e,t){const i=[];for(;","!==e.type.name&&")"!==e.type.name;){const n=t.substring(e.from,e.to);if("NumberLiteral"!==e.type.name)return null;i.push(n),e.next(!1)}if(i.length>3)return null;const n=i.filter((e=>e.includes("%")));if(n.length>2)return null;const s=i.filter((e=>!e.includes("%")));return 1!==s.length?null:{number:Number(s[0]),lengthA:n[0]?Number(n[0].substring(0,n[0].length-1)):void 0,lengthB:n[1]?Number(n[1].substring(0,n[1].length-1)):void 0}}const f={linear:"linear(0 0%, 1 100%)"};class x{#e;constructor(e){this.#e=e}static parse(e){if(f[e])return x.parse(f[e]);const t=function(e){const t=`*{--a: ${e}}`,i=p.parse(t).cursorAt(t.indexOf(":")+1);for(;"ArgList"!==i.name&&i.next(!0);)if("Callee"===i.name&&"linear"!==t.substring(i.from,i.to))return null;if("ArgList"!==i.name)return null;i.firstChild();const n=[];for(;")"!==i.type.name&&i.next(!1);){const e=v(i,t);if(!e)return null;n.push(e)}return n}(e);if(!t||t.length<2)return null;let i=-1/0;const n=[];for(let e=0;e<t.length;e++){const s=t[e],o={input:NaN,output:s.number};if(n.push(o),void 0!==s.lengthA){if(o.input=Math.max(s.lengthA,i),i=o.input,void 0!==s.lengthB){const e={input:NaN,output:o.output};n.push(e),e.input=Math.max(s.lengthB,i),i=e.input}}else 0===e?(o.input=0,i=0):e===t.length-1&&(o.input=Math.max(100,i))}let s=0;for(let e=1;e<n.length;e++)isNaN(n[e].input)&&(e>s&&(s=g(n,e)),n[e].input=n[e-1].input+(n[s].input-n[e-1].input)/(s-(e-1)));return new x(n)}addPoint(e,t){void 0===t?this.#e.push(e):this.#e.splice(t,0,e)}removePoint(e){this.#e.splice(e,1)}setPoint(e,t){this.#e[e]=t}points(){return this.#e}asCSSText(){const e=`linear(${this.#e.map((e=>`${m.format(e.output)} ${m.format(e.input)}%`)).join(", ")})`;for(const[t,i]of Object.entries(f))if(i===e)return t;return e}}var b=Object.freeze({__proto__:null,CSSLinearEasingModel:x});class w{static parse(t){const i=x.parse(t);return i||(e.Geometry.CubicBezier.parse(t)||null)}}const S=e.Geometry.LINEAR_BEZIER;var y=Object.freeze({__proto__:null,AnimationTimingModel:w,LINEAR_BEZIER:S});class C{width;height;marginTop;radius;shouldDrawLine;constructor({width:e,height:t,marginTop:i,controlPointRadius:n,shouldDrawLine:s}){this.width=e,this.height=t,this.marginTop=i,this.radius=n,this.shouldDrawLine=s}static drawVelocityChart(e,t,i){const n=I;let s=["M",0,n];const o=1/40;let r=e.evaluateAt(0);for(let t=o;t<1.025;t+=o){const o=e.evaluateAt(t);let a=(o.y-r.y)/(o.x-r.x);const l=r.x*(1-t)+o.x*t;a=Math.tanh(a/1.5),s=s.concat(["L",(l*i).toFixed(2),(n-a*n).toFixed(2)]),r=o}s=s.concat(["L",i.toFixed(2),n,"Z"]),t.setAttribute("d",s.join(" "))}curveWidth(){return this.width-2*this.radius}curveHeight(){return this.height-2*this.radius-2*this.marginTop}drawLine(t,i,n,s,o,r){const a=e.UIUtils.createSVGChild(t,"line",i);a.setAttribute("x1",String(n+this.radius)),a.setAttribute("y1",String(s+this.radius+this.marginTop)),a.setAttribute("x2",String(o+this.radius)),a.setAttribute("y2",String(r+this.radius+this.marginTop))}drawControlPoints(t,i,n,s,o){this.drawLine(t,"bezier-control-line",i,n,s,o);const r=e.UIUtils.createSVGChild(t,"circle","bezier-control-circle");r.setAttribute("cx",String(s+this.radius)),r.setAttribute("cy",String(o+this.radius+this.marginTop)),r.setAttribute("r",String(this.radius))}drawCurve(t,i){if(!t)return;const n=this.curveWidth(),s=this.curveHeight();i.setAttribute("width",String(this.width)),i.setAttribute("height",String(this.height)),i.removeChildren();const o=e.UIUtils.createSVGChild(i,"g");this.shouldDrawLine&&this.drawLine(o,"linear-line",0,s,n,0);const r=e.UIUtils.createSVGChild(o,"path","bezier-path"),a=[new e.Geometry.Point(t.controlPoints[0].x*n+this.radius,(1-t.controlPoints[0].y)*s+this.radius+this.marginTop),new e.Geometry.Point(t.controlPoints[1].x*n+this.radius,(1-t.controlPoints[1].y)*s+this.radius+this.marginTop),new e.Geometry.Point(n+this.radius,this.marginTop+this.radius)];r.setAttribute("d","M"+this.radius+","+(s+this.radius+this.marginTop)+" C"+a.join(" ")),this.drawControlPoints(o,0,s,t.controlPoints[0].x*n,(1-t.controlPoints[0].y)*s),this.drawControlPoints(o,n,0,t.controlPoints[1].x*n,(1-t.controlPoints[1].y)*s)}}const I=26;var k=Object.freeze({__proto__:null,BezierUI:C,Height:I});class E{#t;#i;#n;#s;#o;#r;#a;constructor({bezier:t,container:i,onBezierChange:n}){this.#i=t,this.#t=new C({width:150,height:250,marginTop:50,controlPointRadius:7,shouldDrawLine:!0}),this.#n=e.UIUtils.createSVGChild(i,"svg","bezier-curve"),this.#a=n,e.UIUtils.installDragHandle(this.#n,this.dragStart.bind(this),this.dragMove.bind(this),this.dragEnd.bind(this),"default")}dragStart(t){this.#s=new e.Geometry.Point(t.x,t.y);const n=this.#t;this.#o=new e.Geometry.Point(i.NumberUtilities.clamp((t.offsetX-n.radius)/n.curveWidth(),0,1),(n.curveHeight()+n.marginTop+n.radius-t.offsetY)/n.curveHeight());const s=this.#o.distanceTo(this.#i.controlPoints[0])<this.#o.distanceTo(this.#i.controlPoints[1]);return this.#r=s?0:1,this.#i.controlPoints[this.#r]=this.#o,this.#a(this.#i),t.consume(!0),!0}updateControlPosition(t,n){if(void 0===this.#s||void 0===this.#o||void 0===this.#r)return;const s=(t-this.#s.x)/this.#t.curveWidth(),o=(n-this.#s.y)/this.#t.curveHeight(),r=new e.Geometry.Point(i.NumberUtilities.clamp(this.#o.x+s,0,1),this.#o.y-o);this.#i.controlPoints[this.#r]=r}dragMove(e){this.updateControlPosition(e.x,e.y),this.#a(this.#i)}dragEnd(e){this.updateControlPosition(e.x,e.y),this.#a(this.#i)}setBezier(e){this.#i=e,this.draw()}draw(){this.#t.drawCurve(this.#i,this.#n)}}class P{params;renderedPositions;constructor(e){this.params=e}#l(){return this.params.width-2*this.params.pointRadius}#h(){return this.params.height-2*this.params.pointRadius-2*this.params.marginTop}#d(t,i,n,s){const o=e.UIUtils.createSVGChild(t,"circle","bezier-control-circle");o.setAttribute("data-point-index",String(s)),o.setAttribute("cx",String(i)),o.setAttribute("cy",String(n)),o.setAttribute("r",String(this.params.pointRadius))}timingPointToPosition(e){return{x:e.input/100*this.#l()+this.params.pointRadius,y:(1-e.output)*this.#h()+this.params.pointRadius}}positionToTimingPoint(e){return{input:(e.x-this.params.pointRadius)/this.#l()*100,output:1-(e.y-this.params.pointRadius)/this.#h()}}draw(t,i){i.setAttribute("width",String(this.#l())),i.setAttribute("height",String(this.#h())),i.removeChildren();const n=e.UIUtils.createSVGChild(i,"g"),s=t.points().map((e=>this.timingPointToPosition(e)));this.renderedPositions=s;let o=s[0];for(let t=1;t<s.length;t++){const i=s[t],r=e.UIUtils.createSVGChild(n,"path","bezier-path linear-path");r.setAttribute("d",`M ${o.x} ${o.y} L ${i.x} ${i.y}`),r.setAttribute("data-line-index",String(t)),o=i}for(let e=0;e<s.length;e++){const t=s[e];this.#d(n,t.x,t.y,e)}}}class T{#c;#u;#p;#m;#g;#v;#s;#f;constructor({model:t,container:i,onChange:n}){this.#c=t,this.#u=n,this.#p=new P({width:150,height:250,pointRadius:7,marginTop:50}),this.#f=e.UIUtils.createSVGChild(i,"svg","bezier-curve linear"),e.UIUtils.installDragHandle(this.#f,this.#x.bind(this),this.#b.bind(this),this.#w.bind(this),"default")}#S(e,t){const i=this.#p.positionToTimingPoint({x:e.offsetX,y:e.offsetY});this.#c.addPoint(i,t),this.#m=void 0,this.#s=void 0}#y(e,t){if(this.#m=t,this.#s={x:e.x,y:e.y},clearTimeout(this.#g),this.#v===this.#m)return this.#c.removePoint(this.#m),this.#v=void 0,this.#m=void 0,void(this.#s=void 0);this.#v=this.#m,this.#g=window.setTimeout((()=>{this.#v=void 0}),500)}#x(e){return e.target instanceof SVGElement&&(void 0!==e.target.dataset.lineIndex?(this.#S(e,Number(e.target.dataset.lineIndex)),e.consume(!0),!0):void 0!==e.target.dataset.pointIndex&&(this.#y(e,Number(e.target.dataset.pointIndex)),e.consume(!0),!0))}#C(e,t){if(void 0===this.#m||void 0===this.#s)return;const i=this.#p.renderedPositions?.[this.#m];if(!i)return;const n=e-this.#s.x,s=t-this.#s.y;this.#s={x:e,y:t};const o={x:i.x+n,y:i.y+s};this.#c.setPoint(this.#m,this.#p.positionToTimingPoint(o))}#b(e){this.#C(e.x,e.y),this.#u(this.#c)}#w(e){this.#C(e.x,e.y),this.#u(this.#c)}setCSSLinearEasingModel(e){this.#c=e,this.draw()}draw(){this.#p.draw(this.#c,this.#f)}}class z{#I;#k;constructor(){this.#I=new P({width:40,height:40,marginTop:0,pointRadius:2}),this.#k=new C({width:40,height:40,marginTop:0,controlPointRadius:2,shouldDrawLine:!1})}draw(t,i){t instanceof x?this.#I.draw(t,i):t instanceof e.Geometry.CubicBezier&&this.#k.drawCurve(t,i)}}class M{#E;#P;#T;#c;#u;#z;#M;constructor({model:t,onChange:i}){this.#E=document.createElement("div"),this.#E.className="animation-timing-ui",this.#E.style.width="150px",this.#E.style.height="250px",this.#P=document.createElement("div"),this.#P.classList.add("bezier-ui-container"),this.#T=document.createElement("div"),this.#T.classList.add("linear-easing-ui-container"),this.#E.appendChild(this.#P),this.#E.appendChild(this.#T),this.#c=t,this.#u=i,this.#c instanceof e.Geometry.CubicBezier?this.#z=new E({bezier:this.#c,container:this.#P,onBezierChange:this.#u}):this.#c instanceof x&&(this.#M=new T({model:this.#c,container:this.#T,onChange:this.#u}))}element(){return this.#E}setModel(t){this.#c=t,this.#c instanceof e.Geometry.CubicBezier?this.#z?this.#z.setBezier(this.#c):this.#z=new E({bezier:this.#c,container:this.#P,onBezierChange:this.#u}):this.#c instanceof x&&(this.#M?this.#M.setCSSLinearEasingModel(this.#c):this.#M=new T({model:this.#c,container:this.#T,onChange:this.#u})),this.draw()}draw(){this.#T.classList.toggle("hidden",!(this.#c instanceof x)),this.#P.classList.toggle("hidden",!(this.#c instanceof e.Geometry.CubicBezier)),this.#z&&this.#z.draw(),this.#M&&this.#M.draw()}}var L=Object.freeze({__proto__:null,PresetUI:z,AnimationTimingUI:M});const U=new CSSStyleSheet;U.replaceSync(":host{width:270px;height:350px;user-select:none;padding:16px;overflow:hidden}.bezier-preset-selected > svg{background-color:var(--legacy-selection-bg-color)}.bezier-container{--override-bezier-control-color:#9c27b0;display:flex;margin-top:38px;flex-shrink:0;z-index:2;background-image:radial-gradient(circle,var(--color-background-elevation-2) 1px,var(--color-background-inverted-opacity-0) 1px);background-size:17px 17px;background-position:-5px -10px}.-theme-with-dark-background .bezier-container,\n:host-context(.-theme-with-dark-background) .bezier-container{--override-bezier-control-color:rgb(196 79 216)}.bezier-preset{width:50px;height:50px;padding:5px;margin:auto;background-color:var(--color-background-elevation-1);border-radius:3px}.bezier-preset line.bezier-control-line{stroke:var(--color-text-secondary);stroke-width:1;stroke-linecap:round;fill:none}.bezier-preset circle.bezier-control-circle{fill:var(--color-text-secondary)}.bezier-preset path.bezier-path{stroke:var(--color-background-inverted);stroke-width:2;stroke-linecap:round;fill:none}.bezier-preset-selected path.bezier-path,\n.bezier-preset-selected line.bezier-control-line{stroke:var(--color-background)}.bezier-preset-selected circle.bezier-control-circle{fill:var(--color-background)}.bezier-curve line.linear-line{stroke:var(--color-background-elevation-2);stroke-width:2;stroke-linecap:round;fill:none}.bezier-curve line.bezier-control-line{stroke:var(--override-bezier-control-color);stroke-width:2;stroke-linecap:round;fill:none;opacity:60%}.bezier-curve circle.bezier-control-circle{fill:var(--override-bezier-control-color);cursor:pointer}.bezier-curve path.bezier-path{stroke:var(--color-background-inverted);stroke-width:3;stroke-linecap:round;fill:none}.bezier-curve path.bezier-path.linear-path{cursor:pointer}.bezier-preview-container{position:relative;background-color:var(--color-background);overflow:hidden;border-radius:20px;width:200%;height:20px;z-index:2;flex-shrink:0;opacity:0%}.bezier-preview-animation{background-color:#9c27b0;width:20px;height:20px;border-radius:20px;position:absolute}.bezier-preview-onion{margin-top:-20px;position:relative;z-index:1}.bezier-preview-onion > .bezier-preview-animation{opacity:10%}svg.bezier-preset-modify{background-color:var(--color-background-elevation-1);border-radius:35px;display:inline-block;visibility:hidden;transition:transform 100ms cubic-bezier(0.4,0,0.2,1);cursor:pointer;position:absolute}svg.bezier-preset-modify:hover,\n.bezier-preset:hover{background-color:var(--color-background-elevation-2)}.bezier-preset-selected .bezier-preset:hover{background-color:var(--legacy-selection-bg-color)}.bezier-preset-modify path{stroke-width:2;stroke:var(--color-background-inverted);fill:none}.bezier-presets{display:flex;flex-direction:column;justify-content:space-between}.bezier-preset-selected .bezier-preset-modify{opacity:100%}.bezier-preset-category{width:50px;cursor:pointer;transition:transform 100ms cubic-bezier(0.4,0,0.2,1)}span.bezier-display-value{width:100%;user-select:text;display:block;text-align:center;line-height:20px;min-height:20px;cursor:text}svg.bezier-curve{margin-left:32px;margin-top:-8px}svg.bezier-curve.linear{margin-top:42px;overflow:visible}svg.bezier-preset-modify.bezier-preset-plus{right:0}.bezier-header{margin-top:16px;z-index:1}svg.bezier-preset-modify:active{transform:scale(1.1);background-color:var(--legacy-selection-bg-color)}.bezier-preset-category:active{transform:scale(1.05)}.bezier-header-active > svg.bezier-preset-modify{visibility:visible}.bezier-preset-modify:active path{stroke:var(--color-background)}\n/*# sourceURL=bezierEditor.css */\n");class A extends(n.ObjectWrapper.eventMixin(e.Widget.VBox)){model;previewElement;previewOnion;outerContainer;selectedCategory;presetsContainer;presetUI;presetCategories;animationTimingUI;header;label;previewAnimation;debouncedStartPreviewAnimation;constructor(e){super(!0),this.model=e,this.contentElement.tabIndex=0,this.setDefaultFocusedElement(this.contentElement),this.element.style.overflowY="auto",this.previewElement=this.contentElement.createChild("div","bezier-preview-container"),this.previewElement.createChild("div","bezier-preview-animation"),this.previewElement.addEventListener("click",this.startPreviewAnimation.bind(this)),this.previewOnion=this.contentElement.createChild("div","bezier-preview-onion"),this.previewOnion.addEventListener("click",this.startPreviewAnimation.bind(this)),this.outerContainer=this.contentElement.createChild("div","bezier-container"),this.selectedCategory=null,this.presetsContainer=this.outerContainer.createChild("div","bezier-presets"),this.presetUI=new z,this.presetCategories=[];for(let e=0;e<R.length;e++){const t=this.createCategory(R[e]);t&&(this.presetCategories[e]=t,this.presetsContainer.appendChild(this.presetCategories[e].icon))}this.debouncedStartPreviewAnimation=n.Debouncer.debounce(this.startPreviewAnimation.bind(this),300),this.animationTimingUI=new M({model:this.model,onChange:e=>{this.setModel(e),this.onchange(),this.unselectPresets(),this.debouncedStartPreviewAnimation()}}),this.outerContainer.appendChild(this.animationTimingUI.element()),this.header=this.contentElement.createChild("div","bezier-header");const t=this.createPresetModifyIcon(this.header,"bezier-preset-minus","M 12 6 L 8 10 L 12 14"),i=this.createPresetModifyIcon(this.header,"bezier-preset-plus","M 8 6 L 12 10 L 8 14");t.addEventListener("click",this.presetModifyClicked.bind(this,!1)),i.addEventListener("click",this.presetModifyClicked.bind(this,!0)),this.label=this.header.createChild("span","source-code bezier-display-value")}setModel(e){this.model=e,this.animationTimingUI?.setModel(this.model),this.updateUI()}wasShown(){this.registerCSSFiles([U]),this.unselectPresets();for(const e of this.presetCategories)for(let t=0;t<e.presets.length;t++)this.model.asCSSText()===e.presets[t].value&&(e.presetIndex=t,this.presetCategorySelected(e));this.updateUI(),this.startPreviewAnimation()}onchange(){this.updateUI(),this.dispatchEventToListeners(F.BezierChanged,this.model.asCSSText())}updateUI(){const e=this.selectedCategory?this.selectedCategory.presets[this.selectedCategory.presetIndex].name:this.model.asCSSText().replace(/\s(-\d\.\d)/g,"$1");this.label.textContent=e,this.animationTimingUI?.draw()}createCategory(t){const i=w.parse(t[0].value);if(!i)return null;const n=document.createElement("div");n.classList.add("bezier-preset-category");const s=e.UIUtils.createSVGChild(n,"svg","bezier-preset monospace"),o={presets:t,presetIndex:0,icon:n};return this.presetUI.draw(i,s),s.addEventListener("click",this.presetCategorySelected.bind(this,o)),o}createPresetModifyIcon(t,i,n){const s=e.UIUtils.createSVGChild(t,"svg","bezier-preset-modify "+i);s.setAttribute("width","20"),s.setAttribute("height","20");return e.UIUtils.createSVGChild(s,"path").setAttribute("d",n),s}unselectPresets(){for(const e of this.presetCategories)e.icon.classList.remove("bezier-preset-selected");this.selectedCategory=null,this.header.classList.remove("bezier-header-active")}presetCategorySelected(e,t){if(this.selectedCategory===e)return;this.unselectPresets(),this.header.classList.add("bezier-header-active"),this.selectedCategory=e,this.selectedCategory.icon.classList.add("bezier-preset-selected");const i=w.parse(e.presets[e.presetIndex].value);i&&(this.setModel(i),this.onchange(),this.startPreviewAnimation()),t&&t.consume(!0)}presetModifyClicked(e,t){if(null===this.selectedCategory)return;const i=this.selectedCategory.presets.length;this.selectedCategory.presetIndex=(this.selectedCategory.presetIndex+(e?1:-1)+i)%i;const n=this.selectedCategory.presets[this.selectedCategory.presetIndex].value,s=w.parse(n);s&&(this.setModel(s),this.onchange(),this.startPreviewAnimation())}startPreviewAnimation(){this.previewOnion.removeChildren(),this.previewAnimation&&this.previewAnimation.cancel();const e=1600;this.previewAnimation=this.previewElement.animate([{offset:0,transform:"translateX(0px)",opacity:1},{offset:1,transform:"translateX(218px)",opacity:1}],{easing:this.model.asCSSText(),duration:e}),this.previewOnion.removeChildren();for(let t=0;t<=20;t++){const i=this.previewOnion.createChild("div","bezier-preview-animation").animate([{transform:"translateX(0px)",easing:this.model.asCSSText()},{transform:"translateX(218px)"}],{duration:e,fill:"forwards"});i.pause(),i.currentTime=e*t/20}}}var F;(F||(F={})).BezierChanged="BezierChanged";const R=[[{name:"linear",value:"linear"},{name:"elastic",value:"linear(0 0%, 0.22 2.1%, 0.86 6.5%, 1.11 8.6%, 1.3 10.7%, 1.35 11.8%, 1.37 12.9%, 1.37 13.7%, 1.36 14.5%, 1.32 16.2%, 1.03 21.8%, 0.94 24%, 0.89 25.9%, 0.88 26.85%, 0.87 27.8%, 0.87 29.25%, 0.88 30.7%, 0.91 32.4%, 0.98 36.4%, 1.01 38.3%, 1.04 40.5%, 1.05 42.7%, 1.05 44.1%, 1.04 45.7%, 1 53.3%, 0.99 55.4%, 0.98 57.5%, 0.99 60.7%, 1 68.1%, 1.01 72.2%, 1 86.7%, 1 100%)"},{name:"bounce",value:"linear(0 0%, 0 2.27%, 0.02 4.53%, 0.04 6.8%, 0.06 9.07%, 0.1 11.33%, 0.14 13.6%, 0.25 18.15%, 0.39 22.7%, 0.56 27.25%, 0.77 31.8%, 1 36.35%, 0.89 40.9%, 0.85 43.18%, 0.81 45.45%, 0.79 47.72%, 0.77 50%, 0.75 52.27%, 0.75 54.55%, 0.75 56.82%, 0.77 59.1%, 0.79 61.38%, 0.81 63.65%, 0.85 65.93%, 0.89 68.2%, 1 72.7%, 0.97 74.98%, 0.95 77.25%, 0.94 79.53%, 0.94 81.8%, 0.94 84.08%, 0.95 86.35%, 0.97 88.63%, 1 90.9%, 0.99 93.18%, 0.98 95.45%, 0.99 97.73%, 1 100%)"},{name:"emphasized",value:"linear(0 0%, 0 1.8%, 0.01 3.6%, 0.03 6.35%, 0.07 9.1%, 0.13 11.4%, 0.19 13.4%, 0.27 15%, 0.34 16.1%, 0.54 18.35%, 0.66 20.6%, 0.72 22.4%, 0.77 24.6%, 0.81 27.3%, 0.85 30.4%, 0.88 35.1%, 0.92 40.6%, 0.94 47.2%, 0.96 55%, 0.98 64%, 0.99 74.4%, 1 86.4%, 1 100%)"}],[{name:"ease-in-out",value:"ease-in-out"},{name:"In Out · Sine",value:"cubic-bezier(0.45, 0.05, 0.55, 0.95)"},{name:"In Out · Quadratic",value:"cubic-bezier(0.46, 0.03, 0.52, 0.96)"},{name:"In Out · Cubic",value:"cubic-bezier(0.65, 0.05, 0.36, 1)"},{name:"Fast Out, Slow In",value:"cubic-bezier(0.4, 0, 0.2, 1)"},{name:"In Out · Back",value:"cubic-bezier(0.68, -0.55, 0.27, 1.55)"}],[{name:"Fast Out, Linear In",value:"cubic-bezier(0.4, 0, 1, 1)"},{name:"ease-in",value:"ease-in"},{name:"In · Sine",value:"cubic-bezier(0.47, 0, 0.75, 0.72)"},{name:"In · Quadratic",value:"cubic-bezier(0.55, 0.09, 0.68, 0.53)"},{name:"In · Cubic",value:"cubic-bezier(0.55, 0.06, 0.68, 0.19)"},{name:"In · Back",value:"cubic-bezier(0.6, -0.28, 0.74, 0.05)"}],[{name:"ease-out",value:"ease-out"},{name:"Out · Sine",value:"cubic-bezier(0.39, 0.58, 0.57, 1)"},{name:"Out · Quadratic",value:"cubic-bezier(0.25, 0.46, 0.45, 0.94)"},{name:"Out · Cubic",value:"cubic-bezier(0.22, 0.61, 0.36, 1)"},{name:"Linear Out, Slow In",value:"cubic-bezier(0, 0, 0.2, 1)"},{name:"Out · Back",value:"cubic-bezier(0.18, 0.89, 0.32, 1.28)"}]];var B=Object.freeze({__proto__:null,BezierEditor:A,get Events(){return F},Presets:R});const N=t.css.cssLanguage.parser;function O(e,t){const i=[];for(;e.nextSibling()&&","!==e.name&&")"!==e.name;)if("ValueName"===e.name||"CallExpression"===e.name||"ColorLiteral"===e.name)i.push({name:"V",value:t.substring(e.from,e.to)});else{if("NumberLiteral"!==e.name)return null;{const n=t.substring(e.from,e.to);if(!n.includes("%"))return null;i.push({name:"P",value:n})}}return i}function D(e){const t=1===e.filter((e=>"V"===e.name)).length,i=e.filter((e=>"P"===e.name)).length<=1;return t&&i}class _{parts;constructor(e){this.parts=e}static parse(e){const t=`*{color:${e};}`,i=N.parse(t).cursorAt(t.indexOf(":")+1);for(;"ArgList"!==i.name&&i.next(!0););if("ArgList"!==i.name)return null;i.firstChild();const n=function(e,t){let i="";for(;e.nextSibling()&&","!==e.name;)i+=t.substring(e.from,e.to)+" ";return","!==e.name?null:{name:"IM",value:i.trimEnd()}}(i,t);if(!n)return null;const s=O(i,t);if(!s)return null;const o=O(i,t);return o&&n.value.startsWith("in")&&D(s)&&D(o)?new _([n,{name:"PA",value:s},{name:"PA",value:o}]):null}}var $=Object.freeze({__proto__:null,ColorMixModel:_});const V=new CSSStyleSheet;V.replaceSync(".swatch-icon{display:inline-grid;inline-size:15px;grid:[stack] 1fr/[stack] 1fr;margin-left:1px;margin-right:2px}.swatch{aspect-ratio:1/1;display:inline-block;width:10px;border-radius:1e5px;background:linear-gradient(var(--color),var(--color)),var(--image-file-checker);box-shadow:inset 0 0 0 .5px rgb(128 128 128/60%);grid-area:stack}.swatch-right{justify-self:end}.swatch-mix{box-shadow:none;justify-self:end;mask:radial-gradient(circle at 0% center,rgb(0 0 0) 50%,rgb(0 0 0/0%) calc(50% + 0.5px));-webkit-mask:radial-gradient(circle at 0% center,rgb(0 0 0) 50%,rgb(0 0 0/0%) calc(50% + 0.5px))}\n/*# sourceURL=colorMixSwatch.css */\n");class H extends HTMLElement{static litTagName=o.literal`devtools-color-mix-swatch`;shadow=this.attachShadow({mode:"open"});colorMixText="";firstColorText="";secondColorText="";constructor(){super(),this.shadow.adoptedStyleSheets=[V]}setFirstColor(e){this.firstColorText&&(this.colorMixText=this.colorMixText.replace(this.firstColorText,e)),this.firstColorText=e,this.#L()}setSecondColor(e){this.secondColorText&&(this.colorMixText=i.StringUtilities.replaceLast(this.colorMixText,this.secondColorText,e)),this.secondColorText=e,this.#L()}setColorMixText(e){this.colorMixText=e,this.#L()}#L(){this.colorMixText&&this.firstColorText&&this.secondColorText?o.render(o.html`<div class="swatch-icon"> <span class="swatch swatch-left" id="swatch-1" style="--color: ${this.firstColorText}"></span> <span class="swatch swatch-right" id="swatch-2" style="--color: ${this.secondColorText}"></span> <span class="swatch swatch-mix" id="mix-result" style="--color: ${this.colorMixText}"></span> </div><slot>${this.colorMixText}</slot>`,this.shadow,{host:this}):o.render(this.colorMixText,this.shadow,{host:this})}}s.CustomElements.defineComponent("devtools-color-mix-swatch",H);var j=Object.freeze({__proto__:null,ColorMixSwatch:H});const G=new CSSStyleSheet;G.replaceSync(":host{white-space:nowrap}.color-swatch{position:relative;margin-left:1px;margin-right:2px;width:12px;height:12px;transform:scale(0.8);vertical-align:-2px;display:inline-block;user-select:none;background-image:var(--image-file-checker);line-height:10px}.color-swatch-inner{width:100%;height:100%;display:inline-block;border:1px solid rgb(128 128 128/60%);box-sizing:border-box;cursor:pointer}.color-swatch:not(.read-only) .color-swatch-inner:hover{border:1px solid rgb(64 64 64/80%)}@media (forced-colors: active){.color-swatch{forced-color-adjust:none}}\n/*# sourceURL=colorSwatch.css */\n");const X={shiftclickToChangeColorFormat:"Shift-click to change color format"},Y=a.i18n.registerUIStrings("ui/legacy/components/inline_editor/ColorSwatch.ts",X),W=a.i18n.getLocalizedString.bind(void 0,Y);class K extends Event{static eventName="colorchanged";data;constructor(e){super(K.eventName,{}),this.data={text:e}}}class q extends Event{static eventName="swatchclick";constructor(){super(q.eventName,{})}}class Z extends HTMLElement{static litTagName=o.literal`devtools-color-swatch`;shadow=this.attachShadow({mode:"open"});tooltip=W(X.shiftclickToChangeColorFormat);text=null;color=null;format=null;constructor(){super(),this.shadow.adoptedStyleSheets=[G]}static isColorSwatch(e){return"devtools-color-swatch"===e.localName}getColor(){return this.color}getFormat(){return this.format}getText(){return this.text}get anchorBox(){const e=this.shadow.querySelector(".color-swatch");return e?e.boxInWindow():null}renderColor(e,t,i){if("string"==typeof e){if(this.color=n.Color.parse(e),this.text=e,!this.color)return void this.renderTextOnly()}else this.color=e;this.format="boolean"==typeof t&&t?n.Settings.detectColorFormat(this.color):"string"==typeof t?n.Color.getFormat(t):this.color.format(),this.text=this.color.getAuthoredText()??this.color.asString(this.format??void 0),i&&(this.tooltip=i),this.render()}renderTextOnly(){o.render(this.text,this.shadow,{host:this})}render(){o.render(o.html`<span class="color-swatch" title="${this.tooltip}"><span class="color-swatch-inner" style="background-color: ${this.text};" @click="${this.onClick}" @mousedown="${this.consume}" @dblclick="${this.consume}"></span></span><slot><span>${this.text}</span></slot>`,this.shadow,{host:this})}onClick(e){if(e.shiftKey)return e.stopPropagation(),void this.showFormatPicker(e);this.dispatchEvent(new q)}consume(e){e.stopPropagation()}setFormat(e){const t=this.color?.as(e),i=t?.asString();t&&i&&(this.color=t,this.format=this.color.format(),this.text=i,this.render(),this.dispatchEvent(new K(this.text)))}showFormatPicker(e){if(!this.color||!this.format)return;new l.FormatPickerContextMenu.FormatPickerContextMenu(this.color,this.format).show(e,(e=>{this.setFormat(e),r.userMetrics.colorConvertedFrom(0)}))}}s.CustomElements.defineComponent("devtools-color-swatch",Z);var Q=Object.freeze({__proto__:null,ColorChangedEvent:K,ClickEvent:q,ColorSwatch:Z});const J=new CSSStyleSheet;J.replaceSync(".css-angle{display:inline-block;position:relative;outline:none}devtools-css-angle-swatch{display:inline-block;margin-right:2px;user-select:none}devtools-css-angle-editor{--override-dial-color:#a3a3a3;position:fixed;z-index:2}.preview{display:inline-block}\n/*# sourceURL=cssAngle.css */\n");const ee=/(?<value>[+-]?\d*\.?\d+)(?<unit>deg|grad|rad|turn)/,te=e=>{const t=e.match(ee);return t&&t.groups?{value:Number(t.groups.value),unit:t.groups.unit}:null},ie=(t,i)=>{let n=t;switch(i){case"grad":n=e.Geometry.radiansToGradians(t);break;case"deg":n=e.Geometry.radiansToDegrees(t);break;case"turn":n=e.Geometry.radiansToTurns(t)}return{value:n,unit:i}},ne=t=>{switch(t.unit){case"deg":return e.Geometry.degreesToRadians(t.value);case"grad":return e.Geometry.gradiansToRadians(t.value);case"turn":return e.Geometry.turnsToRadians(t.value)}return t.value},se=(e,t)=>{const i=ne(e);return{translateX:Math.sin(i)*t,translateY:-Math.cos(i)*t}},oe=e=>{let t=e.value;switch(e.unit){case"deg":case"grad":t=Math.round(e.value);break;case"rad":t=Math.round(1e4*e.value)/1e4;break;case"turn":t=Math.round(100*e.value)/100;break;default:i.assertNever(e.unit,`Unknown angle unit: ${e.unit}`)}return{value:t,unit:e.unit}},re=e=>{switch(e){case"deg":return"grad";case"grad":return"rad";case"rad":return"turn";default:return"deg"}},ae=(e,t)=>{if(e.unit===t)return e;const i=ne(e);return ie(i,t)},le=(t,i)=>{const n=e.UIUtils.getValueModificationDirection(i);if(null===n)return;let s="Up"===n?Math.PI/180:-Math.PI/180;i.shiftKey&&(s*=10);const o=ne(t);return ie(o+s,t.unit)};var he=Object.freeze({__proto__:null,CSSAngleRegex:ee,parseText:te,getAngleFromRadians:ie,getRadiansFromAngle:ne,get2DTranslationsForAngle:se,roundAngleByUnit:oe,getNextUnit:re,convertAngleUnit:ae,getNewAngleFromEvent:le});class de extends Event{static eventName="valuechanged";data;constructor(e){super(de.eventName,{}),this.data={value:e}}}var ce=Object.freeze({__proto__:null,ValueChangedEvent:de});const ue=new CSSStyleSheet;ue.replaceSync('.editor.interacting::before{content:"";position:fixed;inset:0}.clock,\n.pointer,\n.center,\n.hand,\n.dial{position:absolute}.clock{top:6px;width:6em;height:6em;background-color:var(--color-background);border:0.5em solid var(--color-background-elevation-1);border-radius:9em;box-shadow:var(--drop-shadow),inset 0 0 15px var(--box-shadow-outline-color);transform:translateX(-3em)}.center,\n.hand{box-shadow:0 0 2px var(--box-shadow-outline-color)}.pointer{margin:auto;top:0;left:-0.4em;right:0;width:0;height:0;border-style:solid;border-width:0 0.9em 0.9em;border-color:transparent transparent var(--color-background-elevation-1) transparent}.center,\n.hand,\n.dial{margin:auto;top:0;left:0;right:0;bottom:0}.center{width:0.7em;height:0.7em;border-radius:10px}.dial{width:2px;height:var(--clock-dial-length);background-color:var(--override-dial-color);border-radius:1px}.hand{height:50%;width:0.3em;background:var(--legacy-accent-fg-color)}.hand::before{content:"";display:inline-block;position:absolute;top:-0.6em;left:-0.35em;width:1em;height:1em;border-radius:50%;cursor:pointer;box-shadow:0 0 5px var(--box-shadow-outline-color)}.hand::before,\n.center{background-color:var(--legacy-accent-fg-color)}:host-context(.-theme-with-dark-background) .hand::before{box-shadow:0 0 5px hsl(0deg 0% 0%/80%)}:host-context(.-theme-with-dark-background) .center,\n:host-context(.-theme-with-dark-background) .hand{box-shadow:0 0 2px hsl(0deg 0% 0%/60%)}:host-context(.-theme-with-dark-background) .clock{background-color:hsl(225deg 5% 27%)}\n/*# sourceURL=cssAngleEditor.css */\n');const{render:pe,html:me}=o,ge=o.Directives.styleMap;class ve extends HTMLElement{static litTagName=o.literal`devtools-css-angle-editor`;shadow=this.attachShadow({mode:"open"});angle={value:0,unit:"rad"};onAngleUpdate;background="";clockRadius=38.5;dialTemplates;mousemoveThrottler=new n.Throttler.Throttler(16.67);mousemoveListener=this.onMousemove.bind(this);connectedCallback(){this.shadow.adoptedStyleSheets=[ue],s.SetCSSProperty.set(this,"--clock-dial-length","6px")}set data(e){this.angle=e.angle,this.onAngleUpdate=e.onAngleUpdate,this.background=e.background,this.render()}updateAngleFromMousePosition(e,t,i){const n=this.shadow.querySelector(".clock");if(!n||!this.onAngleUpdate)return;const{top:s,right:o,bottom:r,left:a}=n.getBoundingClientRect();this.clockRadius=(o-a)/2;const l=(a+o)/2,h=(r+s)/2,d=-Math.atan2(e-l,t-h)+Math.PI;if(i){const e=ne({value:15,unit:"deg"}),t=Math.round(d/e)*e;this.onAngleUpdate(ie(t,this.angle.unit))}else this.onAngleUpdate(ie(d,this.angle.unit))}onEditorMousedown(e){e.stopPropagation(),this.updateAngleFromMousePosition(e.pageX,e.pageY,e.shiftKey);const t=e.target instanceof Node&&e.target.ownerDocument,i=this.shadow.querySelector(".editor");t&&i&&(t.addEventListener("mousemove",this.mousemoveListener,{capture:!0}),i.classList.add("interacting"),t.addEventListener("mouseup",(()=>{t.removeEventListener("mousemove",this.mousemoveListener,{capture:!0}),i.classList.remove("interacting")}),{once:!0}))}onMousemove(e){1===e.buttons&&(e.preventDefault(),this.mousemoveThrottler.schedule((()=>(this.updateAngleFromMousePosition(e.pageX,e.pageY,e.shiftKey),Promise.resolve()))))}onEditorWheel(e){if(!this.onAngleUpdate)return;const t=le(this.angle,e);t&&this.onAngleUpdate(t),e.preventDefault()}render(){const e={background:this.background},{translateX:t,translateY:i}=se(this.angle,this.clockRadius/2),n={transform:`translate(${t}px, ${i}px) rotate(${this.angle.value}${this.angle.unit})`};pe(me` <div class="editor"> <span class="pointer"></span> <div class="clock" style="${ge(e)}" @mousedown="${this.onEditorMousedown}" @wheel="${this.onEditorWheel}"> ${this.renderDials()} <div class="hand" style="${ge(n)}"></div> <span class="center"></span> </div> </div> `,this.shadow,{host:this})}renderDials(){return this.dialTemplates||(this.dialTemplates=[0,45,90,135,180,225,270,315].map((e=>{const t=this.clockRadius-6-3,{translateX:i,translateY:n}=se({value:e,unit:"deg"},t);return me`<span class="dial" style="${ge({transform:`translate(${i}px, ${n}px) rotate(${e}deg)`})}"></span>`}))),this.dialTemplates}}s.CustomElements.defineComponent("devtools-css-angle-editor",ve);const fe=new CSSStyleSheet;fe.replaceSync(".swatch{position:relative;display:inline-block;margin-bottom:-2px;width:1em;height:1em;border:1px solid var(--legacy-selection-inactive-fg-color);border-radius:50%;overflow:hidden;cursor:pointer;background-color:var(--color-background-elevation-1)}.mini-hand{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;height:55%;width:2px;background-color:var(--legacy-accent-fg-color);border-radius:5px}\n/*# sourceURL=cssAngleSwatch.css */\n");const{render:xe,html:be}=o,we=o.Directives.styleMap;class Se extends HTMLElement{static litTagName=o.literal`devtools-css-angle-swatch`;shadow=this.attachShadow({mode:"open"});angle={value:0,unit:"rad"};connectedCallback(){this.shadow.adoptedStyleSheets=[fe]}set data(e){this.angle=e.angle,this.render()}render(){const{translateX:e,translateY:t}=se(this.angle,2.75),i={transform:`translate(${e}px, ${t}px) rotate(${this.angle.value}${this.angle.unit})`};xe(be` <div class="swatch"> <span class="mini-hand" style="${we(i)}"></span> </div> `,this.shadow,{host:this})}}s.CustomElements.defineComponent("devtools-css-angle-swatch",Se);const{render:ye,html:Ce}=o,Ie=o.Directives.styleMap,ke=new Set(["color","background","background-color"]);class Ee extends Event{static eventName="popovertoggled";data;constructor(e){super(Ee.eventName,{}),this.data={open:e}}}class Pe extends Event{static eventName="unitchanged";data;constructor(e){super(Pe.eventName,{}),this.data={value:e}}}const Te={value:0,unit:"rad"};class ze extends HTMLElement{static litTagName=o.literal`devtools-css-angle`;shadow=this.attachShadow({mode:"open"});angle=Te;displayedAngle=Te;propertyName="";propertyValue="";containingPane;angleElement=null;swatchElement=null;popoverOpen=!1;popoverStyleTop="";popoverStyleLeft="";onMinifyingAction=this.minify.bind(this);connectedCallback(){this.shadow.adoptedStyleSheets=[J]}set data(e){const t=te(e.angleText);t&&(this.angle=t,this.displayedAngle={...t},this.propertyName=e.propertyName,this.propertyValue=e.propertyValue,this.containingPane=e.containingPane,this.render())}disconnectedCallback(){this.unbindMinifyingAction()}popover(){if(!this.containingPane)return;if(this.angleElement||(this.angleElement=this.shadow.querySelector(".css-angle")),this.swatchElement||(this.swatchElement=this.shadow.querySelector("devtools-css-angle-swatch")),!this.angleElement||!this.swatchElement)return;this.dispatchEvent(new Ee(!0)),this.bindMinifyingAction();const e=this.swatchElement.getBoundingClientRect().bottom,t=this.swatchElement.getBoundingClientRect().left;if(e&&t){const i=this.containingPane.getBoundingClientRect().top,n=this.containingPane.getBoundingClientRect().left;this.popoverStyleTop=e-i+"px",this.popoverStyleLeft=t-n+"px"}this.popoverOpen=!0,this.render(),this.angleElement.focus()}minify(){!1!==this.popoverOpen&&(this.popoverOpen=!1,this.dispatchEvent(new Ee(!1)),this.unbindMinifyingAction(),this.render())}updateProperty(e,t){this.propertyName=e,this.propertyValue=t,this.render()}updateAngle(e){this.displayedAngle=oe(ae(e,this.displayedAngle.unit)),this.angle=this.displayedAngle,this.dispatchEvent(new de(`${this.angle.value}${this.angle.unit}`))}displayNextUnit(){const e=re(this.displayedAngle.unit);this.displayedAngle=oe(ae(this.angle,e)),this.dispatchEvent(new Pe(`${this.displayedAngle.value}${this.displayedAngle.unit}`))}bindMinifyingAction(){document.addEventListener("mousedown",this.onMinifyingAction),this.containingPane&&this.containingPane.addEventListener("scroll",this.onMinifyingAction)}unbindMinifyingAction(){document.removeEventListener("mousedown",this.onMinifyingAction),this.containingPane&&this.containingPane.removeEventListener("scroll",this.onMinifyingAction)}onMiniIconClick(e){e.stopPropagation(),!e.shiftKey||this.popoverOpen?this.popoverOpen?this.minify():this.popover():this.displayNextUnit()}consume(e){e.stopPropagation()}onKeydown(e){if(this.popoverOpen)switch(e.key){case"Escape":e.stopPropagation(),this.minify(),this.blur();break;case"ArrowUp":case"ArrowDown":{const t=le(this.angle,e);t&&this.updateAngle(t),e.preventDefault();break}}}render(){ye(Ce` <div class="css-angle" @keydown="${this.onKeydown}" tabindex="-1"> <div class="preview"> <${Se.litTagName} @click="${this.onMiniIconClick}" @mousedown="${this.consume}" @dblclick="${this.consume}" .data="${{angle:this.angle}}"> </${Se.litTagName}><slot></slot></div> ${this.popoverOpen?this.renderPopover():null} </div> `,this.shadow,{host:this})}renderPopover(){let e="";return ke.has(this.propertyName)&&!this.propertyValue.match(/url\(.*\)/i)&&(e=this.propertyValue),Ce` <${ve.litTagName} class="popover popover-css-angle" style="${Ie({top:this.popoverStyleTop,left:this.popoverStyleLeft})}" .data="${{angle:this.angle,onAngleUpdate:e=>{this.updateAngle(e)},background:e}}"></${ve.litTagName}> `}}s.CustomElements.defineComponent("devtools-css-angle",ze);var Me=Object.freeze({__proto__:null,PopoverToggledEvent:Ee,UnitChangedEvent:Pe,CSSAngle:ze});const Le=t.css.cssLanguage.parser,Ue=new Map(Object.entries({normal:"D",alternate:"D",reverse:"D","alternate-reverse":"D",none:"F",forwards:"F",backwards:"F",both:"F",running:"P",paused:"P",infinite:"I",linear:"E",ease:"E","ease-in":"E","ease-out":"E","ease-in-out":"E"}));class Ae{parts;constructor(e){this.parts=e}static parse(t,i){const n=function(e){const t=`*{animation:${e};}`,i=Le.parse(t).cursorAt(t.indexOf(":")+1);i.firstChild(),i.nextSibling();const n=[];for(;i.nextSibling();)n.push(t.substring(i.from,i.to));return n}(t);let s=0;const o=[],r={E:!1,I:!1,D:!1,F:!1,P:!1};for(const t of n){const n=Ue.get(t),a=n&&!r[n];let l="T";if(t.match(e.Geometry.CubicBezier.Regex)&&!r.E?l="EF":t.match(h.CSSMetadata.VariableRegex)?l="V":t!==i[s]||a||(l="AN"),o.push({type:l,value:t}),n&&(r[n]=!0),","===t){for(const e of Object.keys(r))r[e]=!1;s++}}return new Ae(o)}}var Fe=Object.freeze({__proto__:null,CSSAnimationModel:Ae});const Re=new CSSStyleSheet;Re.replaceSync('.css-length{display:inline-block;position:relative;outline:none}.css-length.overloaded{text-decoration:line-through}.value{cursor:ew-resize}.unit-dropdown{display:none}.unit-dropdown select{all:unset;cursor:pointer;opacity:0%;width:0.8em;background-color:var(--color-background)}.icon{position:absolute;display:inline-block;-webkit-mask-image:var(--image-file-chevron-down);-webkit-mask-repeat:no-repeat;background-color:var(--icon-default);transform:scale(0.7);margin-left:-7px;margin-top:-3px;content:"";height:2em;width:2em}:host(:not(:last-child)){margin-right:0.1em}:host(:not(:last-child)) .unit-dropdown{position:absolute}.css-length:hover .unit-dropdown{display:inline-block}:host(:last-child) .unit-dropdown select{width:0.6em}\n/*# sourceURL=cssLength.css */\n');const Be=["px","cm","mm","in","pc","pt","ch","em","rem","vh","vw","vmin","vmax"],Ne=new RegExp(`(?<value>[+-]?\\d*\\.?\\d+)(?<unit>${Be.join("|")})`),Oe=e=>{const t=e.match(Ne);return t&&t.groups?{value:Number(t.groups.value),unit:t.groups.unit}:null};var De=Object.freeze({__proto__:null,LENGTH_UNITS:Be,CSSLengthRegex:Ne,parseText:Oe});const{render:_e,html:$e,Directives:{classMap:Ve}}=o;class He extends Event{static eventName="draggingfinished";constructor(){super(He.eventName,{})}}const je={value:0,unit:"px"};class Ge extends HTMLElement{static litTagName=o.literal`devtools-css-length`;shadow=this.attachShadow({mode:"open"});onDraggingValue=this.dragValue.bind(this);length=je;overloaded=!1;isEditingSlot=!1;isDraggingValue=!1;currentMouseClientX=0;#U=0;set data(e){const t=Oe(e.lengthText);t&&(this.length=t,this.overloaded=e.overloaded,this.render())}connectedCallback(){this.shadow.adoptedStyleSheets=[Re]}onUnitChange(e){this.length.unit=e.target.value,this.dispatchEvent(new de(`${this.length.value}${this.length.unit}`)),this.dispatchEvent(new He),this.render()}dragValue(e){if(e.preventDefault(),e.stopPropagation(),Date.now()-this.#U<=300)return;this.isDraggingValue=!0;let t=e.clientX-this.currentMouseClientX;this.currentMouseClientX=e.clientX,e.shiftKey&&(t*=10),e.altKey&&(t*=.1),this.length.value=this.length.value+t,this.dispatchEvent(new de(`${this.length.value}${this.length.unit}`)),this.render()}onValueMousedown(e){if(0!==e.button)return;this.#U=Date.now(),this.currentMouseClientX=e.clientX;const t=e.target instanceof Node&&e.target.ownerDocument;t&&(t.addEventListener("mousemove",this.onDraggingValue,{capture:!0}),t.addEventListener("mouseup",(e=>{t.removeEventListener("mousemove",this.onDraggingValue,{capture:!0}),this.isDraggingValue&&(e.preventDefault(),e.stopPropagation(),this.isDraggingValue=!1,this.dispatchEvent(new He))}),{once:!0,capture:!0}))}onValueMouseup(){this.isDraggingValue||(this.isEditingSlot=!0,this.render())}onUnitMouseup(e){e.preventDefault(),e.stopPropagation(),r.userMetrics.swatchActivated(8)}render(){const e={"css-length":!0,overloaded:this.overloaded};_e($e` <div class="${Ve(e)}"> ${this.renderContent()} </div> `,this.shadow,{host:this})}renderContent(){if(this.isEditingSlot)return $e`<slot></slot>`;const e=Be.map((e=>$e` <option value="${e}" .selected="${this.length.unit===e}">${e}</option> `));return $e` <span class="value" @mousedown="${this.onValueMousedown}" @mouseup="${this.onValueMouseup}">${this.length.value}</span><span class="unit">${this.length.unit}</span><div class="unit-dropdown"> <span class="icon"></span> <select @mouseup="${this.onUnitMouseup}" @change="${this.onUnitChange}"> ${e} </select> </div> `}}s.CustomElements.defineComponent("devtools-css-length",Ge);var Xe=Object.freeze({__proto__:null,DraggingFinishedEvent:He,CSSLength:Ge});class Ye{isBoxShadowInternal;insetInternal;offsetXInternal;offsetYInternal;blurRadiusInternal;spreadRadiusInternal;colorInternal;format;important;constructor(e){this.isBoxShadowInternal=e,this.insetInternal=!1,this.offsetXInternal=We.zero(),this.offsetYInternal=We.zero(),this.blurRadiusInternal=We.zero(),this.spreadRadiusInternal=We.zero(),this.colorInternal=n.Color.parse("black"),this.format=["X","Y"],this.important=!1}static parseTextShadow(e){return Ye.parseShadow(e,!1)}static parseBoxShadow(e){return Ye.parseShadow(e,!0)}static parseShadow(e,t){const i=[],s=d.TextUtils.Utils.splitStringByRegexes(e,[n.Color.Regex,/,/g]);let o=0;for(let t=0;t<s.length;t++)if(1===s[t].regexIndex){const n=s[t];i.push(e.substring(o,n.position)),o=n.position+1}i.push(e.substring(o,e.length));const r=[];for(let e=0;e<i.length;e++){const s=new Ye(t);s.format=[];let o=!0;const l=[/!important/gi,/inset/gi,n.Color.Regex,We.Regex],h=d.TextUtils.Utils.splitStringByRegexes(i[e],l);for(let e=0;e<h.length;e++){const t=h[e];if(-1===t.regexIndex){if(/\S/.test(t.value))return[];o=!0}else{if(!o)return[];if(o=!1,0===t.regexIndex)s.important=!0,s.format.push("M");else if(1===t.regexIndex)s.insetInternal=!0,s.format.push("I");else if(2===t.regexIndex){const e=n.Color.parse(t.value);if(!e)return[];s.colorInternal=e,s.format.push("C")}else if(3===t.regexIndex){const e=We.parse(t.value);if(!e)return[];const i=s.format.length>0?s.format[s.format.length-1]:"";"X"===i?(s.offsetYInternal=e,s.format.push("Y")):"Y"===i?(s.blurRadiusInternal=e,s.format.push("B")):"B"===i?(s.spreadRadiusInternal=e,s.format.push("S")):(s.offsetXInternal=e,s.format.push("X"))}}}if(a(s,"X",1,1)||a(s,"Y",1,1)||a(s,"C",0,1)||a(s,"B",0,1)||a(s,"I",0,t?1:0)||a(s,"S",0,t?1:0)||a(s,"M",0,1))return[];r.push(s)}return r;function a(e,t,i,n){let s=0;for(let i=0;i<e.format.length;i++)e.format[i]===t&&s++;return s<i||s>n}}setInset(e){this.insetInternal=e,-1===this.format.indexOf("I")&&this.format.unshift("I")}setOffsetX(e){this.offsetXInternal=e}setOffsetY(e){this.offsetYInternal=e}setBlurRadius(e){if(this.blurRadiusInternal=e,-1===this.format.indexOf("B")){const e=this.format.indexOf("Y");this.format.splice(e+1,0,"B")}}setSpreadRadius(e){if(this.spreadRadiusInternal=e,-1===this.format.indexOf("S")){this.setBlurRadius(this.blurRadiusInternal);const e=this.format.indexOf("B");this.format.splice(e+1,0,"S")}}setColor(e){this.colorInternal=e,-1===this.format.indexOf("C")&&this.format.push("C")}isBoxShadow(){return this.isBoxShadowInternal}inset(){return this.insetInternal}offsetX(){return this.offsetXInternal}offsetY(){return this.offsetYInternal}blurRadius(){return this.blurRadiusInternal}spreadRadius(){return this.spreadRadiusInternal}color(){return this.colorInternal}asCSSText(){const e=[];for(let t=0;t<this.format.length;t++){const i=this.format[t];"I"===i&&this.insetInternal?e.push("inset"):"X"===i?e.push(this.offsetXInternal.asCSSText()):"Y"===i?e.push(this.offsetYInternal.asCSSText()):"B"===i?e.push(this.blurRadiusInternal.asCSSText()):"S"===i?e.push(this.spreadRadiusInternal.asCSSText()):"C"===i?e.push(this.colorInternal.getAuthoredText()??this.colorInternal.asString()):"M"===i&&this.important&&e.push("!important")}return e.join(" ")}}class We{amount;unit;constructor(e,t){this.amount=e,this.unit=t}static parse(e){const t=new RegExp("^(?:"+We.Regex.source+")$","i"),i=e.match(t);return i?i.length>2&&i[2]?new We(parseFloat(i[1]),i[2]):We.zero():null}static zero(){return new We(0,"")}asCSSText(){return this.amount+this.unit}static Regex=function(){return new RegExp("([+-]?(?:[0-9]*[.])?[0-9]+(?:[eE][+-]?[0-9]+)?)(ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw)|[+-]?(?:0*[.])?0+(?:[eE][+-]?[0-9]+)?","gi")}()}var Ke=Object.freeze({__proto__:null,CSSShadowModel:Ye,CSSLength:We});const qe=new CSSStyleSheet;qe.replaceSync(":host{user-select:none;padding:4px 12px 12px;border:1px solid transparent}.shadow-editor-field{height:24px;margin-top:8px;font-size:12px;flex-shrink:0}.shadow-editor-field:last-of-type{margin-bottom:8px}.shadow-editor-flex-field{display:flex;align-items:center;flex-direction:row}.shadow-editor-field.shadow-editor-blur-field{margin-top:40px}.shadow-editor-2D-slider{position:absolute;height:88px;width:88px;border:1px solid var(--divider-line);border-radius:2px}.shadow-editor-label{display:inline-block;width:52px;height:24px;line-height:24px;margin-right:8px;text-align:right}.shadow-editor-button-left,\n.shadow-editor-button-right{width:74px;height:24px;padding:3px 7px;line-height:16px;border:1px solid var(--divider-line);color:var(--color-text-primary);background-color:var(--color-background);text-align:center;font-weight:500}.shadow-editor-button-left{border-radius:2px 0 0 2px}.shadow-editor-button-right{border-radius:0 2px 2px 0;border-left-width:0}.shadow-editor-button-left:hover,\n.shadow-editor-button-right:hover{box-shadow:0 1px 1px var(--color-background-elevation-1)}.shadow-editor-button-left:focus,\n.shadow-editor-button-right:focus{background-color:var(--color-background-elevation-1)}.shadow-editor-button-left.enabled,\n.shadow-editor-button-right.enabled{--override-button-text-color:#fff;background-color:var(--color-primary-old);color:var(--override-button-text-color)}.shadow-editor-button-left.enabled:focus,\n.shadow-editor-button-right.enabled:focus{background-color:var(--color-primary-variant)}.shadow-editor-text-input{width:52px;margin-right:8px;text-align:right;box-shadow:var(--legacy-focus-ring-inactive-shadow)}@media (forced-colors: active){.shadow-editor-button-left:hover,\n  .shadow-editor-button-left.enabled:focus,\n  .shadow-editor-button-right:hover .shadow-editor-button-left.enabled,\n  .shadow-editor-button-right.enabled,\n  .shadow-editor-button-right.enabled:focus{forced-color-adjust:none;background-color:Highlight;color:HighlightText}}\n/*# sourceURL=cssShadowEditor.css */\n");const Ze={type:"Type",xOffset:"X offset",yOffset:"Y offset",blur:"Blur",spread:"Spread"},Qe=a.i18n.registerUIStrings("ui/legacy/components/inline_editor/CSSShadowEditor.ts",Ze),Je=a.i18n.getLocalizedString.bind(void 0,Qe);class et extends(n.ObjectWrapper.eventMixin(e.Widget.VBox)){typeField;outsetButton;insetButton;xInput;yInput;xySlider;halfCanvasSize;innerCanvasSize;blurInput;blurSlider;spreadField;spreadInput;spreadSlider;model;canvasOrigin;changedElement;constructor(){super(!0),this.contentElement.tabIndex=0,this.setDefaultFocusedElement(this.contentElement),this.typeField=this.contentElement.createChild("div","shadow-editor-field shadow-editor-flex-field"),this.typeField.createChild("label","shadow-editor-label").textContent=Je(Ze.type),this.outsetButton=this.typeField.createChild("button","shadow-editor-button-left"),this.outsetButton.textContent=a.i18n.lockedString("Outset"),this.outsetButton.addEventListener("click",this.onButtonClick.bind(this),!1),this.insetButton=this.typeField.createChild("button","shadow-editor-button-right"),this.insetButton.textContent=a.i18n.lockedString("Inset"),this.insetButton.addEventListener("click",this.onButtonClick.bind(this),!1);const t=this.contentElement.createChild("div","shadow-editor-field");this.xInput=this.createTextInput(t,Je(Ze.xOffset));const i=this.contentElement.createChild("div","shadow-editor-field");this.yInput=this.createTextInput(i,Je(Ze.yOffset)),this.xySlider=t.createChild("canvas","shadow-editor-2D-slider"),this.xySlider.width=88,this.xySlider.height=88,this.xySlider.tabIndex=-1,this.halfCanvasSize=44,this.innerCanvasSize=this.halfCanvasSize-6,e.UIUtils.installDragHandle(this.xySlider,this.dragStart.bind(this),this.dragMove.bind(this),null,"default"),this.xySlider.addEventListener("keydown",this.onCanvasArrowKey.bind(this),!1),this.xySlider.addEventListener("blur",this.onCanvasBlur.bind(this),!1);const n=this.contentElement.createChild("div","shadow-editor-field shadow-editor-flex-field shadow-editor-blur-field");this.blurInput=this.createTextInput(n,Je(Ze.blur)),this.blurSlider=this.createSlider(n),this.spreadField=this.contentElement.createChild("div","shadow-editor-field shadow-editor-flex-field"),this.spreadInput=this.createTextInput(this.spreadField,Je(Ze.spread)),this.spreadSlider=this.createSlider(this.spreadField)}createTextInput(t,i){const n=t.createChild("label","shadow-editor-label");n.textContent=i,n.setAttribute("for",i);const s=e.UIUtils.createInput("shadow-editor-text-input","text");return t.appendChild(s),s.id=i,s.addEventListener("keydown",this.handleValueModification.bind(this),!1),s.addEventListener("wheel",this.handleValueModification.bind(this),!1),s.addEventListener("input",this.onTextInput.bind(this),!1),s.addEventListener("blur",this.onTextBlur.bind(this),!1),s}createSlider(t){const i=e.UIUtils.createSlider(0,20,-1);return i.addEventListener("input",this.onSliderInput.bind(this),!1),t.appendChild(i),i}wasShown(){this.registerCSSFiles([qe]),this.updateUI()}setModel(e){this.model=e,this.typeField.classList.toggle("hidden",!e.isBoxShadow()),this.spreadField.classList.toggle("hidden",!e.isBoxShadow()),this.updateUI()}updateUI(){this.updateButtons(),this.xInput.value=this.model.offsetX().asCSSText(),this.yInput.value=this.model.offsetY().asCSSText(),this.blurInput.value=this.model.blurRadius().asCSSText(),this.spreadInput.value=this.model.spreadRadius().asCSSText(),this.blurSlider.value=this.model.blurRadius().amount.toString(),this.spreadSlider.value=this.model.spreadRadius().amount.toString(),this.updateCanvas(!1)}updateButtons(){this.insetButton.classList.toggle("enabled",this.model.inset()),this.outsetButton.classList.toggle("enabled",!this.model.inset())}updateCanvas(e){const t=this.xySlider.getContext("2d");if(!t)throw new Error("Unable to obtain canvas context");t.clearRect(0,0,this.xySlider.width,this.xySlider.height),t.save(),t.setLineDash([1,1]),t.strokeStyle="rgba(210, 210, 210, 0.8)",t.beginPath(),t.moveTo(this.halfCanvasSize,0),t.lineTo(this.halfCanvasSize,88),t.moveTo(0,this.halfCanvasSize),t.lineTo(88,this.halfCanvasSize),t.stroke(),t.restore();const i=this.sliderThumbPosition();t.save(),t.translate(this.halfCanvasSize,this.halfCanvasSize),t.lineWidth=2,t.strokeStyle="rgba(130, 130, 130, 0.75)",t.beginPath(),t.moveTo(0,0),t.lineTo(i.x,i.y),t.stroke(),e&&(t.beginPath(),t.fillStyle="rgba(66, 133, 244, 0.4)",t.arc(i.x,i.y,8,0,2*Math.PI),t.fill()),t.beginPath(),t.fillStyle="#4285F4",t.arc(i.x,i.y,6,0,2*Math.PI),t.fill(),t.restore()}onButtonClick(e){const t=e.currentTarget===this.insetButton;t&&this.model.inset()||!t&&!this.model.inset()||(this.model.setInset(t),this.updateButtons(),this.dispatchEventToListeners(tt.ShadowChanged,this.model))}handleValueModification(t){const i=t.currentTarget,n=e.UIUtils.createReplacementString(i.value,t,(function(e,t,i){i.length||(i="px");return e+t+i}));if(!n)return;const s=We.parse(n);s&&(t.currentTarget===this.blurInput&&s.amount<0&&(s.amount=0),i.value=s.asCSSText(),i.selectionStart=0,i.selectionEnd=i.value.length,this.onTextInput(t),t.consume(!0))}onTextInput(e){const t=e.currentTarget;this.changedElement=t,this.changedElement.classList.remove("invalid");const i=We.parse(t.value);!i||t===this.blurInput&&i.amount<0||(t===this.xInput?(this.model.setOffsetX(i),this.updateCanvas(!1)):t===this.yInput?(this.model.setOffsetY(i),this.updateCanvas(!1)):t===this.blurInput?(this.model.setBlurRadius(i),this.blurSlider.value=i.amount.toString()):t===this.spreadInput&&(this.model.setSpreadRadius(i),this.spreadSlider.value=i.amount.toString()),this.dispatchEventToListeners(tt.ShadowChanged,this.model))}onTextBlur(){if(!this.changedElement)return;let e=this.changedElement.value.trim()?We.parse(this.changedElement.value):We.zero();if(e||(e=We.parse(this.changedElement.value+"px")),!e)return this.changedElement.classList.add("invalid"),void(this.changedElement=null);this.changedElement===this.xInput?(this.model.setOffsetX(e),this.xInput.value=e.asCSSText(),this.updateCanvas(!1)):this.changedElement===this.yInput?(this.model.setOffsetY(e),this.yInput.value=e.asCSSText(),this.updateCanvas(!1)):this.changedElement===this.blurInput?(e.amount<0&&(e=We.zero()),this.model.setBlurRadius(e),this.blurInput.value=e.asCSSText(),this.blurSlider.value=e.amount.toString()):this.changedElement===this.spreadInput&&(this.model.setSpreadRadius(e),this.spreadInput.value=e.asCSSText(),this.spreadSlider.value=e.amount.toString()),this.changedElement=null,this.dispatchEventToListeners(tt.ShadowChanged,this.model)}onSliderInput(e){e.currentTarget===this.blurSlider?(this.model.setBlurRadius(new We(Number(this.blurSlider.value),this.model.blurRadius().unit||"px")),this.blurInput.value=this.model.blurRadius().asCSSText(),this.blurInput.classList.remove("invalid")):e.currentTarget===this.spreadSlider&&(this.model.setSpreadRadius(new We(Number(this.spreadSlider.value),this.model.spreadRadius().unit||"px")),this.spreadInput.value=this.model.spreadRadius().asCSSText(),this.spreadInput.classList.remove("invalid")),this.dispatchEventToListeners(tt.ShadowChanged,this.model)}dragStart(t){this.xySlider.focus(),this.updateCanvas(!0),this.canvasOrigin=new e.Geometry.Point(this.xySlider.getBoundingClientRect().left+this.halfCanvasSize,this.xySlider.getBoundingClientRect().top+this.halfCanvasSize);const i=new e.Geometry.Point(t.x-this.canvasOrigin.x,t.y-this.canvasOrigin.y),n=this.sliderThumbPosition();return i.distanceTo(n)>=6&&this.dragMove(t),!0}dragMove(t){let i=new e.Geometry.Point(t.x-this.canvasOrigin.x,t.y-this.canvasOrigin.y);t.shiftKey&&(i=this.snapToClosestDirection(i));const n=this.constrainPoint(i,this.innerCanvasSize),s=Math.round(n.x/this.innerCanvasSize*20),o=Math.round(n.y/this.innerCanvasSize*20);t.shiftKey?(this.model.setOffsetX(new We(s,this.model.offsetX().unit||"px")),this.model.setOffsetY(new We(o,this.model.offsetY().unit||"px"))):(t.altKey||this.model.setOffsetX(new We(s,this.model.offsetX().unit||"px")),e.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(t)||this.model.setOffsetY(new We(o,this.model.offsetY().unit||"px"))),this.xInput.value=this.model.offsetX().asCSSText(),this.yInput.value=this.model.offsetY().asCSSText(),this.xInput.classList.remove("invalid"),this.yInput.classList.remove("invalid"),this.updateCanvas(!0),this.dispatchEventToListeners(tt.ShadowChanged,this.model)}onCanvasBlur(){this.updateCanvas(!1)}onCanvasArrowKey(e){const t=e;let n=0,s=0;if("ArrowRight"===t.key?n=1:"ArrowLeft"===t.key?n=-1:"ArrowUp"===t.key?s=-1:"ArrowDown"===t.key&&(s=1),n||s){if(e.consume(!0),n){const e=this.model.offsetX(),t=i.NumberUtilities.clamp(e.amount+n,-20,20);if(t===e.amount)return;this.model.setOffsetX(new We(t,e.unit||"px")),this.xInput.value=this.model.offsetX().asCSSText(),this.xInput.classList.remove("invalid")}if(s){const e=this.model.offsetY(),t=i.NumberUtilities.clamp(e.amount+s,-20,20);if(t===e.amount)return;this.model.setOffsetY(new We(t,e.unit||"px")),this.yInput.value=this.model.offsetY().asCSSText(),this.yInput.classList.remove("invalid")}this.updateCanvas(!0),this.dispatchEventToListeners(tt.ShadowChanged,this.model)}}constrainPoint(t,i){return Math.abs(t.x)<=i&&Math.abs(t.y)<=i?new e.Geometry.Point(t.x,t.y):t.scale(i/Math.max(Math.abs(t.x),Math.abs(t.y)))}snapToClosestDirection(t){let i=Number.MAX_VALUE,n=t;const s=[new e.Geometry.Point(0,-1),new e.Geometry.Point(1,-1),new e.Geometry.Point(1,0),new e.Geometry.Point(1,1)];for(const e of s){const s=t.projectOn(e),o=t.distanceTo(s);o<i&&(i=o,n=s)}return n}sliderThumbPosition(){const t=this.model.offsetX().amount/20*this.innerCanvasSize,i=this.model.offsetY().amount/20*this.innerCanvasSize;return this.constrainPoint(new e.Geometry.Point(t,i),this.innerCanvasSize)}}var tt;(tt||(tt={})).ShadowChanged="ShadowChanged";var it=Object.freeze({__proto__:null,CSSShadowEditor:et,get Events(){return tt}});const nt=new CSSStyleSheet;nt.replaceSync(":host{user-select:none;padding:4px 12px 12px}.error-input{box-shadow:0 0 0 1px var(--color-accent-red)}.error-text{color:var(--color-accent-red);padding:6px 0}.warning-input{--override-warning-input-color:#ffdd9e;box-shadow:0 0 0 1px var(--override-warning-input-color)}.-theme-with-dark-background .warning-input,\n:host-context(.-theme-with-dark-background) .warning-input{--override-warning-input-color:rgb(97 63 0)}.hide-warning{display:none}.font-section-header{font-weight:normal;font-size:17px;text-align:left}.font-section-subheader{font-size:12px;text-align:left;font-weight:bold}.font-selector-section{overflow-y:auto;padding-bottom:10px}.font-selector-input{width:204px;text-align-last:center}.font-reset-button{width:100%;margin-top:10px}.font-section{border-top:1px solid var(--color-details-hairline)}.chrome-select.font-editor-select{min-width:50px;min-height:27px}input::-webkit-outer-spin-button,\ninput::-webkit-inner-spin-button{display:none;margin:0}.preview-text{max-width:300px;word-break:break-word;display:block}.rendered-font-list-label{font-weight:bold;font-size:12px}.rendered-font-list{padding:5px 0}.shadow-editor-field{height:24px;margin-top:8px;font-size:12px;flex-shrink:0}.shadow-editor-field:last-of-type{margin-bottom:8px}.shadow-editor-flex-field{display:flex;align-items:center;flex-direction:row}.shadow-editor-field.shadow-editor-blur-field{margin-top:40px}.shadow-editor-2D-slider{position:absolute;height:88px;width:88px;border:1px solid var(--divider-line);border-radius:2px}.shadow-editor-label{display:inline-block;width:70px;height:24px;line-height:24px;margin-right:8px;text-align:left}.shadow-editor-button-left,\n.shadow-editor-button-right{width:74px;height:24px;padding:3px 7px;line-height:16px;border:1px solid var(--divider-line);color:var(--color-text-primary);background-color:var(--color-background);text-align:center;font-weight:500}.shadow-editor-button-left{border-radius:2px 0 0 2px}.shadow-editor-button-right{border-radius:0 2px 2px 0;border-left-width:0}.shadow-editor-button-left:hover,\n.shadow-editor-button-right:hover{box-shadow:0 1px 1px var(--divider-line)}.shadow-editor-button-left:focus,\n.shadow-editor-button-right:focus{background-color:var(--color-background-elevation-1)}.shadow-editor-text-input{width:50px;margin:8px;text-align:center;box-shadow:var(--legacy-focus-ring-inactive-shadow)}.spectrum-switcher{border-radius:2px;height:20px;width:20px;padding:2px;margin-left:5px}.spectrum-switcher:hover{background-color:var(--color-background-elevation-1)}.spectrum-switcher:focus-visible{background-color:var(--legacy-focus-bg-color)}\n/*# sourceURL=fontEditor.css */\n");async function st(t){const i=e.Context.Context.instance().flavor(h.DOMModel.DOMNode);let n;if(i&&i.parentNode&&"HTML"!==i.nodeName()){const[e]=h.TargetManager.TargetManager.instance().models(u.CSSOverviewModel.CSSOverviewModel),s=t?i.parentNode.id:i.id,o=(await e.getComputedStyleForNode(s).then(ot)).replace(/[a-z]/g,"");n=parseFloat(o)}else n=16;return n}function ot(e){const t=e.computedStyle;let i=6;if(t[i].name&&"font-size"!==t[i].name)for(let e=0;e<t.length;e++)if("font-size"===t[e].name){i=e;break}return t[i].value}const rt={expression:"window.innerWidth",includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1,userGesture:!1,awaitPromise:!0,throwOnSideEffect:!1,disableBreaks:!0,replMode:!1,allowUnsafeEvalBlockedByCSP:!1},at={expression:"window.innerHeight",includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1,userGesture:!1,awaitPromise:!0,throwOnSideEffect:!1,disableBreaks:!0,replMode:!1,allowUnsafeEvalBlockedByCSP:!1};async function lt(){const t=e.Context.Context.instance().flavor(h.RuntimeModel.ExecutionContext);let i,n;if(t){const e=await t.evaluate(rt,!1,!1),s=await t.evaluate(at,!1,!1);if("error"in e||"error"in s)return null;e.object&&(i=e.object.value),s.object&&(n=s.object.value)}if(void 0===i||void 0===n){const t=e.Context.Context.instance().flavor(h.DOMModel.DOMNode);if(!t)return null;const s=await t.domModel().target().pageAgent().invoke_getLayoutMetrics(),o=s.visualViewport.zoom?s.visualViewport.zoom:1;n=s.visualViewport.clientHeight/o,i=s.visualViewport.clientWidth/o}return{width:i,height:n}}const ht=new Map;async function dt(e,t,i){let n,s;""===e&&(e="em"),""===t&&(t="em");const o=ht.get(e),r=ht.get(t);return o&&r?(n="em"===e||"%"===e?await o(i):await o(),s="em"===t||"%"===t?await r(i):await r(),n/s):1}ht.set("px",(function(){return 1})),ht.set("em",st),ht.set("rem",(async function(){const t=function(e){let t=e;for(;t&&"HTML"!==t.nodeName()&&t.parentNode;)t=t.parentNode;return t}(e.Context.Context.instance().flavor(h.DOMModel.DOMNode));if(!t||!t.id)return 16;const[i]=h.TargetManager.TargetManager.instance().models(u.CSSOverviewModel.CSSOverviewModel),n=(await i.getComputedStyleForNode(t.id).then(ot)).replace(/[a-z]/g,"");return parseFloat(n)})),ht.set("%",(async function(e){return await st(e)/100})),ht.set("vh",(async function(){const e=await lt();return e?e.height/100:1})),ht.set("vw",(async function(){const e=await lt();return e?e.width/100:1})),ht.set("vmin",(async function(){const e=await lt();if(!e)return 1;const t=e.width,i=e.height;return Math.min(t,i)/100})),ht.set("vmax",(async function(){const e=await lt();if(!e)return 1;const t=e.width,i=e.height;return Math.max(t,i)/100})),ht.set("cm",(function(){return 37.795})),ht.set("mm",(function(){return 3.7795})),ht.set("in",(function(){return 96})),ht.set("pt",(function(){return 4/3})),ht.set("pc",(function(){return 16}));var ct=Object.freeze({__proto__:null,getUnitConversionMultiplier:dt});const ut=new Set(["px","em","rem","%","vh","vw"]),pt=new Set(["","px","em","%"]),mt=new Set(["em","rem","px"]),gt=["","xx-small","x-small","smaller","small","medium","large","larger","x-large","xx-large"],vt=["","normal"],ft=["","lighter","normal","bold","bolder"],xt=["","normal"],bt=["inherit","initial","unset"];gt.push(...bt),vt.push(...bt),ft.push(...bt),xt.push(...bt);const wt=new Set(gt),St=new Set(vt),yt=new Set(ft),Ct=new Set(xt),It=new Map([["px",{min:0,max:72,step:1}],["em",{min:0,max:4.5,step:.1}],["rem",{min:0,max:4.5,step:.1}],["%",{min:0,max:450,step:1}],["vh",{min:0,max:10,step:.1}],["vw",{min:0,max:10,step:.1}],["vmin",{min:0,max:10,step:.1}],["vmax",{min:0,max:10,step:.1}],["cm",{min:0,max:2,step:.1}],["mm",{min:0,max:20,step:.1}],["in",{min:0,max:1,step:.01}],["pt",{min:0,max:54,step:1}],["pc",{min:0,max:4.5,step:.1}]]),kt=new Map([["",{min:0,max:2,step:.1}],["em",{min:0,max:2,step:.1}],["%",{min:0,max:200,step:1}],["px",{min:0,max:32,step:1}],["rem",{min:0,max:2,step:.1}],["vh",{min:0,max:4.5,step:.1}],["vw",{min:0,max:4.5,step:.1}],["vmin",{min:0,max:4.5,step:.1}],["vmax",{min:0,max:4.5,step:.1}],["cm",{min:0,max:1,step:.1}],["mm",{min:0,max:8.5,step:.1}],["in",{min:0,max:.5,step:.1}],["pt",{min:0,max:24,step:1}],["pc",{min:0,max:2,step:.1}]]),Et=new Map([["",{min:100,max:700,step:100}]]),Pt=new Map([["px",{min:-10,max:10,step:.01}],["em",{min:-.625,max:.625,step:.001}],["rem",{min:-.625,max:.625,step:.001}],["%",{min:-62.5,max:62.5,step:.1}],["vh",{min:-1.5,max:1.5,step:.01}],["vw",{min:-1.5,max:1.5,step:.01}],["vmin",{min:-1.5,max:1.5,step:.01}],["vmax",{min:-1.5,max:1.5,step:.01}],["cm",{min:-.25,max:.025,step:.001}],["mm",{min:-2.5,max:2.5,step:.01}],["in",{min:-.1,max:.1,step:.001}],["pt",{min:-7.5,max:7.5,step:.01}],["pc",{min:-.625,max:.625,step:.001}]]),Tt={regex:/(^[\+\d\.]+)([a-zA-Z%]+)/,units:ut,keyValues:wt,rangeMap:It,defaultUnit:"px"},zt={regex:/(^[\+\d\.]+)([a-zA-Z%]*)/,units:pt,keyValues:St,rangeMap:kt,defaultUnit:""},Mt={regex:/(^[\+\d\.]+)/,units:null,keyValues:yt,rangeMap:Et,defaultUnit:null},Lt={regex:/([\+-0-9\.]+)([a-zA-Z%]+)/,units:mt,keyValues:Ct,rangeMap:Pt,defaultUnit:"em"},Ut=["Arial","Bookman","Candara","Comic Sans MS","Courier New","Garamond","Georgia","Helvetica","Impact","Palatino","Roboto","Times New Roman","Verdana"],At=["serif","sans-serif","monspace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"];async function Ft(){const e=h.TargetManager.TargetManager.instance().models(u.CSSOverviewModel.CSSOverviewModel);if(e){const t=e[0];if(t){const{fontInfo:e}=await t.getNodeStyleStats();return Array.from(e.keys())}}return[]}function Rt(e){switch(e){case 1:default:return 0;case.1:return 1;case.01:return 2;case.001:return 3}}var Bt=Object.freeze({__proto__:null,FontPropertiesRegex:/^[^- ][a-zA-Z-]+|-?\+?(?:[0-9]+\.[0-9]+|\.[0-9]+|[0-9]+)[a-zA-Z%]{0,4}/,FontFamilyRegex:/(?:"[\w \,-]+",? ?|'[\w \,-]+',? ?|[\w \,-]+,? ?)+/,GlobalValues:bt,FontSizeStaticParams:Tt,LineHeightStaticParams:zt,FontWeightStaticParams:Mt,LetterSpacingStaticParams:Lt,SystemFonts:Ut,GenericFonts:At,generateComputedFontArray:Ft,getRoundingPrecision:Rt});const Nt={fontFamily:"Font Family",cssProperties:"CSS Properties",fontSize:"Font Size",lineHeight:"Line Height",fontWeight:"Font Weight",spacing:"Spacing",fallbackS:"Fallback {PH1}",thereIsNoValueToDeleteAtIndexS:"There is no value to delete at index: {PH1}",fontSelectorDeletedAtIndexS:"Font Selector deleted at index: {PH1}",deleteS:"Delete {PH1}",PleaseEnterAValidValueForSText:"* Please enter a valid value for {PH1} text input",thisPropertyIsSetToContainUnits:"This property is set to contain units but does not have a defined corresponding unitsArray: {PH1}",sSliderInput:"{PH1} Slider Input",sTextInput:"{PH1} Text Input",units:"Units",sUnitInput:"{PH1} Unit Input",sKeyValueSelector:"{PH1} Key Value Selector",sToggleInputType:"{PH1} toggle input type",selectorInputMode:"Selector Input Mode",sliderInputMode:"Slider Input Mode"},Ot=a.i18n.registerUIStrings("ui/legacy/components/inline_editor/FontEditor.ts",Nt),Dt=a.i18n.getLocalizedString.bind(void 0,Ot);class _t extends(n.ObjectWrapper.eventMixin(e.Widget.VBox)){selectedNode;propertyMap;fontSelectorSection;fontSelectors;fontsList;constructor(t){super(!0),this.selectedNode=e.Context.Context.instance().flavor(h.DOMModel.DOMNode),this.propertyMap=t,this.contentElement.tabIndex=0,this.setDefaultFocusedElement(this.contentElement),this.fontSelectorSection=this.contentElement.createChild("div","font-selector-section"),this.fontSelectorSection.createChild("h2","font-section-header").textContent=Dt(Nt.fontFamily),this.fontSelectors=[],this.fontsList=null;const i=this.propertyMap.get("font-family");this.createFontSelectorSection(i);const n=this.contentElement.createChild("div","font-section");n.createChild("h2","font-section-header").textContent=Dt(Nt.cssProperties);const s=this.getPropertyInfo("font-size",Tt.regex),o=this.getPropertyInfo("line-height",zt.regex),r=this.getPropertyInfo("font-weight",Mt.regex),a=this.getPropertyInfo("letter-spacing",Lt.regex);new Vt("font-size",Dt(Nt.fontSize),n,s,Tt,this.updatePropertyValue.bind(this),this.resizePopout.bind(this),!0),new Vt("line-height",Dt(Nt.lineHeight),n,o,zt,this.updatePropertyValue.bind(this),this.resizePopout.bind(this),!0),new Vt("font-weight",Dt(Nt.fontWeight),n,r,Mt,this.updatePropertyValue.bind(this),this.resizePopout.bind(this),!1),new Vt("letter-spacing",Dt(Nt.spacing),n,a,Lt,this.updatePropertyValue.bind(this),this.resizePopout.bind(this),!0)}wasShown(){this.registerCSSFiles([nt])}async createFontSelectorSection(e){if(e){const t=e.split(",");if(await this.createFontSelector(t[0],!0),!bt.includes(t[0]))for(let e=1;e<t.length+1;e++)this.createFontSelector(t[e])}else this.createFontSelector("",!0);this.resizePopout()}async createFontsList(){const e=await Ft(),t=new Map,i=this.splitComputedFontArray(e);t.set("Computed Fonts",i);const n=new Map;n.set("System Fonts",Ut),n.set("Generic Families",At);const s=[];return s.push(t),s.push(n),s}splitComputedFontArray(e){const t=[];for(const i of e)if(i.includes(",")){i.split(",").forEach((e=>{-1===t.findIndex((t=>t.toLowerCase()===e.trim().toLowerCase().replace(/"/g,"'")))&&t.push(e.trim().replace(/"/g,""))}))}else-1===t.findIndex((e=>e.toLowerCase()===i.toLowerCase().replace('"',"'")))&&t.push(i.replace(/"/g,""));return t}async createFontSelector(e,t){if(e=e?e.trim():""){const t=e.charAt(0);"'"===t?e=e.replace(/'/g,""):'"'===t&&(e=e.replace(/"/g,""))}const i=this.fontSelectorSection.createChild("div","shadow-editor-field shadow-editor-flex-field");let n;if(this.fontsList||(this.fontsList=await this.createFontsList()),t){n=Dt(Nt.fontFamily);const t=new Map([["Global Values",bt]]),s=[...this.fontsList];s.push(t),this.createSelector(i,n,s,e.trim())}else n=Dt(Nt.fallbackS,{PH1:this.fontSelectors.length}),this.createSelector(i,n,this.fontsList,e.trim())}deleteFontSelector(t,i){let n=this.fontSelectors[t];const s=0===t;if(""===n.input.value&&!i)return void e.ARIAUtils.alert(Dt(Nt.thereIsNoValueToDeleteAtIndexS,{PH1:t}));if(s){const e=this.fontSelectors[1];let i="";e&&(i=e.input.value,n=e);this.fontSelectors[0].input.value=i,t=1}if(n.input.parentNode){const i=this.fontSelectors.length>1;if(!s||i){const e=n.input.parentElement;e&&(e.remove(),this.fontSelectors.splice(t,1),this.updateFontSelectorList())}e.ARIAUtils.alert(Dt(Nt.fontSelectorDeletedAtIndexS,{PH1:t}))}this.onFontSelectorChanged(),this.resizePopout();const o=s?0:t-1;this.fontSelectors[o].input.focus()}updateFontSelectorList(){for(let t=0;t<this.fontSelectors.length;t++){const i=this.fontSelectors[t];let n;n=0===t?Dt(Nt.fontFamily):Dt(Nt.fallbackS,{PH1:t}),i.label.textContent=n,e.ARIAUtils.setLabel(i.input,n),i.deleteButton.setTitle(Dt(Nt.deleteS,{PH1:n})),i.index=t}}getPropertyInfo(e,t){const i=this.propertyMap.get(e);if(i){const e=i,n=e.match(t);if(n){return{value:"+"===n[1].charAt(0)?n[1].substr(1):n[1],units:n[2]?n[2]:""}}return{value:e,units:null}}return{value:null,units:null}}createSelector(t,n,s,o){const r=this.fontSelectors.length,a=e.UIUtils.createSelect(n,s);a.value=o;const l=e.UIUtils.createLabel(n,"shadow-editor-label",a);a.addEventListener("input",this.onFontSelectorChanged.bind(this),!1),a.addEventListener("keydown",(e=>{"Enter"===e.key&&e.consume()}),!1),t.appendChild(l),t.appendChild(a);const h=new e.Toolbar.Toolbar("",t),d=new e.Toolbar.ToolbarButton(Dt(Nt.deleteS,{PH1:n}),"bin");h.appendToolbarItem(d);const c={label:l,input:a,deleteButton:d,index:r};d.addEventListener(e.Toolbar.ToolbarButton.Events.Click,(()=>{this.deleteFontSelector(c.index)})),d.element.addEventListener("keydown",(e=>{i.KeyboardUtilities.isEnterOrSpaceKey(e)&&(this.deleteFontSelector(c.index),e.consume())}),!1),this.fontSelectors.push(c)}onFontSelectorChanged(){let e="";const t=bt.includes(this.fontSelectors[0].input.value);if(t)for(let e=1;e<this.fontSelectors.length;e++)this.deleteFontSelector(e,!0);for(const t of this.fontSelectors){const i=t.input;""!==i.value&&(""===e?e=this.fontSelectors[0].input.value:e+=", "+i.value)}""!==this.fontSelectors[this.fontSelectors.length-1].input.value&&!t&&this.fontSelectors.length<10&&(this.createFontSelector(""),this.resizePopout()),this.updatePropertyValue("font-family",e)}updatePropertyValue(e,t){this.dispatchEventToListeners($t.FontChanged,{propertyName:e,value:t})}resizePopout(){this.dispatchEventToListeners($t.FontEditorResized)}}var $t;!function(e){e.FontChanged="FontChanged",e.FontEditorResized="FontEditorResized"}($t||($t={}));class Vt{showSliderMode;errorText;propertyInfo;propertyName;staticParams;hasUnits;units;addedUnit;initialRange;boundUpdateCallback;boundResizeCallback;selectedNode;sliderInput;textBoxInput;unitInput;selectorInput;applyNextInput;constructor(t,i,n,s,o,r,a,l){this.showSliderMode=!0;const d=n.createChild("div","shadow-editor-field shadow-editor-flex-field");if(this.errorText=n.createChild("div","error-text"),this.errorText.textContent=Dt(Nt.PleaseEnterAValidValueForSText,{PH1:t}),this.errorText.hidden=!0,e.ARIAUtils.markAsAlert(this.errorText),this.propertyInfo=s,this.propertyName=t,this.staticParams=o,this.hasUnits=l,this.hasUnits&&this.staticParams.units&&null!==this.staticParams.defaultUnit){const e=this.staticParams.defaultUnit;this.units=null!==s.units?s.units:e,this.addedUnit=!this.staticParams.units.has(this.units)}else{if(this.hasUnits)throw new Error(Dt(Nt.thisPropertyIsSetToContainUnits,{PH1:t}));this.units=""}this.initialRange=this.getUnitRange(),this.boundUpdateCallback=r,this.boundResizeCallback=a,this.selectedNode=e.Context.Context.instance().flavor(h.DOMModel.DOMNode);const c=e.UIUtils.createLabel(i,"shadow-editor-label");d.append(c),this.sliderInput=this.createSliderInput(d,i),this.textBoxInput=this.createTextBoxInput(d),e.ARIAUtils.bindLabelToControl(c,this.textBoxInput),this.unitInput=this.createUnitInput(d),this.selectorInput=this.createSelectorInput(d),this.createTypeToggle(d),this.checkSelectorValueAndToggle(),this.applyNextInput=!1}setInvalidTextBoxInput(e){e?this.errorText.hidden&&(this.errorText.hidden=!1,this.textBoxInput.classList.add("error-input"),this.boundResizeCallback()):this.errorText.hidden||(this.errorText.hidden=!0,this.textBoxInput.classList.remove("error-input"),this.boundResizeCallback())}checkSelectorValueAndToggle(){return!(!this.staticParams.keyValues||null===this.propertyInfo.value||!this.staticParams.keyValues.has(this.propertyInfo.value))&&(this.toggleInputType(),!0)}getUnitRange(){let e=0,t=100,i=1;if(null!==this.propertyInfo.value&&/\d/.test(this.propertyInfo.value))if(this.staticParams.rangeMap.get(this.units)){const n=this.staticParams.rangeMap.get(this.units);n&&(e=Math.min(n.min,parseFloat(this.propertyInfo.value)),t=Math.max(n.max,parseFloat(this.propertyInfo.value)),i=n.step)}else{const n=this.staticParams.rangeMap.get("px");n&&(e=Math.min(n.min,parseFloat(this.propertyInfo.value)),t=Math.max(n.max,parseFloat(this.propertyInfo.value)),i=n.step)}else{const n=this.staticParams.rangeMap.get(this.units);n&&(e=n.min,t=n.max,i=n.step)}return{min:e,max:t,step:i}}createSliderInput(t,i){const n=this.initialRange.min,s=this.initialRange.max,o=this.initialRange.step,r=e.UIUtils.createSlider(n,s,-1);if(r.sliderElement.step=o.toString(),r.sliderElement.tabIndex=0,this.propertyInfo.value)r.value=parseFloat(this.propertyInfo.value);else{const e=(n+s)/2;r.value=e}return r.addEventListener("input",(e=>{this.onSliderInput(e,!1)})),r.addEventListener("mouseup",(e=>{this.onSliderInput(e,!0)})),r.addEventListener("keydown",(e=>{"ArrowUp"!==e.key&&"ArrowDown"!==e.key&&"ArrowLeft"!==e.key&&"ArrowRight"!==e.key||(this.applyNextInput=!0)})),t.appendChild(r),e.ARIAUtils.setLabel(r.sliderElement,Dt(Nt.sSliderInput,{PH1:this.propertyName})),r}createTextBoxInput(t){const i=e.UIUtils.createInput("shadow-editor-text-input","number");return i.step=this.initialRange.step.toString(),i.classList.add("font-editor-text-input"),null!==this.propertyInfo.value&&("+"===this.propertyInfo.value.charAt(0)&&(this.propertyInfo.value=this.propertyInfo.value.substr(1)),i.value=this.propertyInfo.value),i.step="any",i.addEventListener("input",this.onTextBoxInput.bind(this),!1),t.appendChild(i),e.ARIAUtils.setLabel(i,Dt(Nt.sTextInput,{PH1:this.propertyName})),i}createUnitInput(t){let i;if(this.hasUnits&&this.staticParams.units){const t=this.propertyInfo.units,n=this.staticParams.units;i=e.UIUtils.createSelect(Dt(Nt.units),n),i.classList.add("font-editor-select"),this.addedUnit&&t&&i.add(new Option(t,t)),t&&(i.value=t),i.addEventListener("change",this.onUnitInput.bind(this),!1)}else i=e.UIUtils.createSelect(Dt(Nt.units),[]),i.classList.add("font-editor-select"),i.disabled=!0;return i.addEventListener("keydown",(e=>{"Enter"===e.key&&e.consume()}),!1),t.appendChild(i),e.ARIAUtils.setLabel(i,Dt(Nt.sUnitInput,{PH1:this.propertyName})),i}createSelectorInput(t){const i=e.UIUtils.createSelect(Dt(Nt.sKeyValueSelector,{PH1:this.propertyName}),this.staticParams.keyValues);return i.classList.add("font-selector-input"),this.propertyInfo.value&&(i.value=this.propertyInfo.value),i.addEventListener("input",this.onSelectorInput.bind(this),!1),i.addEventListener("keydown",(e=>{"Enter"===e.key&&e.consume()}),!1),t.appendChild(i),i.hidden=!0,i}onSelectorInput(e){if(e.currentTarget){const t=e.currentTarget.value;this.textBoxInput.value="";const i=(parseFloat(this.sliderInput.sliderElement.min)+parseFloat(this.sliderInput.sliderElement.max))/2;this.sliderInput.value=i,this.setInvalidTextBoxInput(!1),this.boundUpdateCallback(this.propertyName,t)}}onSliderInput(e,t){const i=e.currentTarget;if(i){const e=i.value;this.textBoxInput.value=e,this.selectorInput.value="";const n=this.hasUnits?e+this.unitInput.value:e.toString();this.setInvalidTextBoxInput(!1),(t||this.applyNextInput)&&(this.boundUpdateCallback(this.propertyName,n),this.applyNextInput=!1)}}onTextBoxInput(e){const t=e.currentTarget;if(t){const e=t.value,i=e+(""===e?"":this.unitInput.value);this.staticParams.regex.test(i)||""===e&&!t.validationMessage.length?(parseFloat(e)>parseFloat(this.sliderInput.sliderElement.max)?this.sliderInput.sliderElement.max=e:parseFloat(e)<parseFloat(this.sliderInput.sliderElement.min)&&(this.sliderInput.sliderElement.min=e),this.sliderInput.value=parseFloat(e),this.selectorInput.value="",this.setInvalidTextBoxInput(!1),this.boundUpdateCallback(this.propertyName,i)):this.setInvalidTextBoxInput(!0)}}async onUnitInput(e){const t=e.currentTarget,i=t.hasFocus(),n=t.value;t.disabled=!0;const s=this.units,o=await dt(s,n,"font-size"===this.propertyName);this.setInputUnits(o,n),this.textBoxInput.value&&this.boundUpdateCallback(this.propertyName,this.textBoxInput.value+n),this.units=n,t.disabled=!1,i&&t.focus()}createTypeToggle(t){const i=t.createChild("div","spectrum-switcher"),n=new c.Icon.Icon;n.data={iconName:"fold-more",color:"var(--icon-default)",width:"16px",height:"16px"},i.appendChild(n),e.UIUtils.setTitle(i,Dt(Nt.sToggleInputType,{PH1:this.propertyName})),i.tabIndex=0,self.onInvokeElement(i,this.toggleInputType.bind(this)),e.ARIAUtils.markAsButton(i)}toggleInputType(t){t&&"Enter"===t.key&&t.consume(),this.showSliderMode?(this.sliderInput.hidden=!0,this.textBoxInput.hidden=!0,this.unitInput.hidden=!0,this.selectorInput.hidden=!1,this.showSliderMode=!1,e.ARIAUtils.alert(Dt(Nt.selectorInputMode))):(this.sliderInput.hidden=!1,this.textBoxInput.hidden=!1,this.unitInput.hidden=!1,this.selectorInput.hidden=!0,this.showSliderMode=!0,e.ARIAUtils.alert(Dt(Nt.sliderInputMode)))}setInputUnits(e,t){const i=this.staticParams.rangeMap.get(t);let n,s,o;i?(n=i.min,s=i.max,o=i.step):(n=0,s=100,o=1);let r=!1;const a=Rt(o);let l=(n+s)/2;this.textBoxInput.value&&(r=!0,l=parseFloat((parseFloat(this.textBoxInput.value)*e).toFixed(a))),this.sliderInput.sliderElement.min=Math.min(l,n).toString(),this.sliderInput.sliderElement.max=Math.max(l,s).toString(),this.sliderInput.sliderElement.step=o.toString(),this.textBoxInput.step=o.toString(),r&&(this.textBoxInput.value=l.toString()),this.sliderInput.value=l}}var Ht=Object.freeze({__proto__:null,FontEditor:_t,get Events(){return $t}});const jt=new CSSStyleSheet;jt.replaceSync(".link-swatch-link:not(.undefined){cursor:pointer;text-underline-offset:2px;color:var(--color-link)}.link-swatch-link:hover:not(.undefined){text-decoration:underline}.link-swatch-link:focus:not(:focus-visible){outline:none}.link-swatch-link.undefined{--override-link-swatch-link-undefined-color:rgb(102 102 102);color:var(--override-link-swatch-link-undefined-color)}\n/*# sourceURL=linkSwatch.css */\n");const Gt={sIsNotDefined:"{PH1} is not defined"},Xt=a.i18n.registerUIStrings("ui/legacy/components/inline_editor/LinkSwatch.ts",Gt),Yt=a.i18n.getLocalizedString.bind(void 0,Xt),{render:Wt,html:Kt,Directives:qt}=o;class Zt extends HTMLElement{static litTagName=o.literal`devtools-base-link-swatch`;shadow=this.attachShadow({mode:"open"});onLinkActivate=()=>{};connectedCallback(){this.shadow.adoptedStyleSheets=[jt]}set data(e){this.onLinkActivate=(t,n)=>{n instanceof MouseEvent&&0!==n.button||n instanceof KeyboardEvent&&!i.KeyboardUtilities.isEnterOrSpaceKey(n)||(e.onLinkActivate(t),n.consume(!0))},e.showTitle=void 0===e.showTitle||e.showTitle,this.render(e)}render(e){const{isDefined:t,text:i,title:n}=e,s=qt.classMap({"link-swatch-link":!0,undefined:!t}),r=t?this.onLinkActivate.bind(this,i.trim()):null;Wt(Kt`<span class="${s}" title="${o.Directives.ifDefined(e.showTitle?n:null)}" data-title="${o.Directives.ifDefined(e.showTitle?null:n)}" @mousedown="${r}" @keydown="${r}" role="link" tabindex="-1">${i}</span>`,this.shadow,{host:this})}}const Qt=/(^var\()\s*(--(?:[\s\w\P{ASCII}-]|\\.)+)(,?\s*.*)\s*(\))$/u;class Jt extends HTMLElement{static litTagName=o.literal`devtools-css-var-swatch`;shadow=this.attachShadow({mode:"open"});constructor(){super(),this.tabIndex=-1,this.addEventListener("focus",(()=>{const e=this.shadow.querySelector('[role="link"]');e&&e.focus()}))}set data(e){this.render(e)}parseVariableFunctionParts(e){const t=e.replace(/\s{2,}/g," ").match(Qt);return t?{pre:t[1],variableName:t[2],fallbackIncludeComma:t[3],post:t[4]}:null}variableName(e){const t=e.match(Qt);return t?t[2]:""}render(e){const{text:t,fromFallback:i,computedValue:n,onLinkActivate:s}=e,o=this.parseVariableFunctionParts(t);if(!o)return void Wt("",this.shadow,{host:this});const r=Boolean(n)&&!i,a=r?n:Yt(Gt.sIsNotDefined,{PH1:this.variableName(t)}),l=o.fallbackIncludeComma?o.fallbackIncludeComma:"";Wt(Kt`<span data-title="${e.computedValue||""}">${o.pre}<${Zt.litTagName} .data="${{title:a,showTitle:!1,text:o.variableName,isDefined:r,onLinkActivate:s}}" class="css-var-link"></${Zt.litTagName}>${l}${o.post}</span>`,this.shadow,{host:this})}}class ei extends HTMLElement{static litTagName=o.literal`devtools-link-swatch`;shadow=this.attachShadow({mode:"open"});set data(e){this.render(e)}render(e){const{text:t,isDefined:i,onLinkActivate:n}=e,s=i?t:Yt(Gt.sIsNotDefined,{PH1:t});Wt(Kt`<span title="${e.text}"><${Zt.litTagName} .data="${{text:t,isDefined:i,title:s,onLinkActivate:n}}"></${Zt.litTagName}></span>`,this.shadow,{host:this})}}s.CustomElements.defineComponent("devtools-base-link-swatch",Zt),s.CustomElements.defineComponent("devtools-link-swatch",ei),s.CustomElements.defineComponent("devtools-css-var-swatch",Jt);var ti=Object.freeze({__proto__:null,CSSVarSwatch:Jt,LinkSwatch:ei});const ii=new CSSStyleSheet;ii.replaceSync(':host{white-space:nowrap}[is="ui-icon"].icon-mask.bezier-swatch-icon{position:relative;transform:scale(0.7);margin:-5px -2px -6px -4px;user-select:none;background-color:var(--icon-css);cursor:default}[is="ui-icon"].icon-mask.bezier-swatch-icon:hover{background-color:var(--icon-css-hover)}\n/*# sourceURL=bezierSwatch.css */\n');const ni=new CSSStyleSheet;ni.replaceSync(':host{white-space:nowrap}[is="ui-icon"].shadow-swatch-icon{background-color:var(--icon-css);transform:scale(0.7);position:relative;margin:-5px -2px -5px -4px;user-select:none}[is="ui-icon"].shadow-swatch-icon:hover{background-color:var(--icon-css-hover)}\n/*# sourceURL=cssShadowSwatch.css */\n');class si extends HTMLSpanElement{iconElementInternal;textElement;constructor(){super();const t=e.Utils.createShadowRootWithCoreStyles(this,{cssFile:[ii],delegatesFocus:void 0});this.iconElementInternal=e.Icon.Icon.create("bezier-curve-filled","bezier-swatch-icon"),t.appendChild(this.iconElementInternal),this.textElement=this.createChild("span"),t.createChild("slot")}static create(){let t=si.constructorInternal;return t||(t=e.Utils.registerCustomElement("span","bezier-swatch",si),si.constructorInternal=t),t()}bezierText(){return this.textElement.textContent||""}setBezierText(e){this.textElement.textContent=e}hideText(e){this.textElement.hidden=e}iconElement(){return this.iconElementInternal}static constructorInternal=null}class oi extends HTMLSpanElement{iconElementInternal;contentElement;colorSwatchInternal;modelInternal;constructor(){super();const t=e.Utils.createShadowRootWithCoreStyles(this,{cssFile:[ni],delegatesFocus:void 0});this.iconElementInternal=e.Icon.Icon.create("shadow","shadow-swatch-icon"),t.appendChild(this.iconElementInternal),t.createChild("slot"),this.contentElement=this.createChild("span")}static create(){let t=oi.constructorInternal;return t||(t=e.Utils.registerCustomElement("span","css-shadow-swatch",oi),oi.constructorInternal=t),t()}model(){return this.modelInternal}setCSSShadow(e){this.modelInternal=e,this.contentElement.removeChildren();const t=d.TextUtils.Utils.splitStringByRegexes(e.asCSSText(),[/!important/g,/inset/g,n.Color.Regex]);for(let i=0;i<t.length;i++){const n=t[i];if(2===n.regexIndex){if(!this.colorSwatchInternal){this.colorSwatchInternal=new Z;const e=this.colorSwatchInternal.createChild("span");this.colorSwatchInternal.addEventListener(K.eventName,(t=>{e.textContent=t.data.text}))}this.colorSwatchInternal.renderColor(e.color());const t=this.colorSwatchInternal.querySelector("span");t&&(t.textContent=e.color().getAuthoredText()??e.color().asString()),this.contentElement.appendChild(this.colorSwatchInternal)}else this.contentElement.appendChild(document.createTextNode(n.value))}}hideText(e){this.contentElement.hidden=e}iconElement(){return this.iconElementInternal}colorSwatch(){return this.colorSwatchInternal}static constructorInternal=null}var ri=Object.freeze({__proto__:null,BezierSwatch:si,CSSShadowSwatch:oi});const ai=new CSSStyleSheet;ai.replaceSync(".widget{display:flex;background:var(--color-background);box-shadow:var(--drop-shadow);border-radius:2px;overflow:auto;user-select:text;line-height:11px}\n/*# sourceURL=swatchPopover.css */\n");class li extends n.ObjectWrapper.ObjectWrapper{popover;hideProxy;boundOnKeyDown;boundFocusOut;isHidden;anchorElement;view;hiddenCallback;focusRestorer;constructor(){super(),this.popover=new e.GlassPane.GlassPane,this.popover.setSizeBehavior("MeasureContent"),this.popover.setMarginBehavior("Arrow"),this.popover.element.addEventListener("mousedown",(e=>e.consume()),!1),this.hideProxy=this.hide.bind(this,!0),this.boundOnKeyDown=this.onKeyDown.bind(this),this.boundFocusOut=this.onFocusOut.bind(this),this.isHidden=!0,this.anchorElement=null}onFocusOut(e){const t=e.relatedTarget;!this.isHidden&&t&&this.view&&!t.isSelfOrDescendant(this.view.contentElement)&&this.hideProxy()}setAnchorElement(e){this.anchorElement=e}isShowing(e){return this.popover.isShowing()&&(e&&this.view===e||!e)}show(e,t,i){if(this.popover.isShowing()){if(this.anchorElement===t)return;this.hide(!0)}this.popover.registerCSSFiles([ai]),this.dispatchEventToListeners(hi.WillShowPopover),this.isHidden=!1,this.anchorElement=t,this.view=e,this.hiddenCallback=i,this.reposition(),e.focus();const n=this.popover.element.ownerDocument;n.addEventListener("mousedown",this.hideProxy,!1),n.defaultView&&n.defaultView.addEventListener("resize",this.hideProxy,!1),this.view.contentElement.addEventListener("keydown",this.boundOnKeyDown,!1)}reposition(){if(!this.isHidden&&this.view){if(this.view.contentElement.removeEventListener("focusout",this.boundFocusOut,!1),this.view.show(this.popover.contentElement),this.anchorElement){let e=this.anchorElement.boxInWindow();if(Z.isColorSwatch(this.anchorElement)){const t=this.anchorElement;if(!t.anchorBox)return;e=t.anchorBox}this.popover.setContentAnchorBox(e),this.popover.show(this.anchorElement.ownerDocument)}this.view.contentElement.addEventListener("focusout",this.boundFocusOut,!1),this.focusRestorer||(this.focusRestorer=new e.Widget.WidgetFocusRestorer(this.view))}}hide(e){if(this.isHidden)return;const t=this.popover.element.ownerDocument;this.isHidden=!0,this.popover.hide(),t.removeEventListener("mousedown",this.hideProxy,!1),t.defaultView&&t.defaultView.removeEventListener("resize",this.hideProxy,!1),this.hiddenCallback&&this.hiddenCallback.call(null,Boolean(e)),this.focusRestorer&&this.focusRestorer.restore(),this.anchorElement=null,this.view&&(this.view.detach(),this.view.contentElement.removeEventListener("keydown",this.boundOnKeyDown,!1),this.view.contentElement.removeEventListener("focusout",this.boundFocusOut,!1),delete this.view)}onKeyDown(e){if("Enter"===e.key)return this.hide(!0),void e.consume(!0);e.key===i.KeyboardUtilities.ESCAPE_KEY&&(this.hide(!1),e.consume(!0))}}var hi;!function(e){e.WillShowPopover="WillShowPopover"}(hi||(hi={}));var di=Object.freeze({__proto__:null,SwatchPopoverHelper:li,get Events(){return hi}});export{y as AnimationTimingModel,L as AnimationTimingUI,B as BezierEditor,k as BezierUI,Me as CSSAngle,he as CSSAngleUtils,Fe as CSSAnimationModel,Xe as CSSLength,De as CSSLengthUtils,b as CSSLinearEasingModel,it as CSSShadowEditor,Ke as CSSShadowModel,$ as ColorMixModel,j as ColorMixSwatch,Q as ColorSwatch,Ht as FontEditor,ct as FontEditorUnitConverter,Bt as FontEditorUtils,ce as InlineEditorUtils,ti as LinkSwatch,di as SwatchPopoverHelper,ri as Swatches};
